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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
400
albertvision/MRestFramework
src/Maleeby/MRest/Routing.php
Routing.analizeUri
public static function analizeUri() { $uri = self::getUri(); $uriInfo = pathinfo($uri); if (!isset($uriInfo['dirname']) || $uriInfo['dirname'] == '.') { $uriInfo['dirname'] = ''; } return [ 'type' => isset($uriInfo['extension']) ? $uriInfo['extension'] : MRest::getConfig()['contentType'], 'uri' => self::fixUri($uriInfo['dirname'] . '/' . $uriInfo['filename']) ]; }
php
public static function analizeUri() { $uri = self::getUri(); $uriInfo = pathinfo($uri); if (!isset($uriInfo['dirname']) || $uriInfo['dirname'] == '.') { $uriInfo['dirname'] = ''; } return [ 'type' => isset($uriInfo['extension']) ? $uriInfo['extension'] : MRest::getConfig()['contentType'], 'uri' => self::fixUri($uriInfo['dirname'] . '/' . $uriInfo['filename']) ]; }
[ "public", "static", "function", "analizeUri", "(", ")", "{", "$", "uri", "=", "self", "::", "getUri", "(", ")", ";", "$", "uriInfo", "=", "pathinfo", "(", "$", "uri", ")", ";", "if", "(", "!", "isset", "(", "$", "uriInfo", "[", "'dirname'", "]", ")", "||", "$", "uriInfo", "[", "'dirname'", "]", "==", "'.'", ")", "{", "$", "uriInfo", "[", "'dirname'", "]", "=", "''", ";", "}", "return", "[", "'type'", "=>", "isset", "(", "$", "uriInfo", "[", "'extension'", "]", ")", "?", "$", "uriInfo", "[", "'extension'", "]", ":", "MRest", "::", "getConfig", "(", ")", "[", "'contentType'", "]", ",", "'uri'", "=>", "self", "::", "fixUri", "(", "$", "uriInfo", "[", "'dirname'", "]", ".", "'/'", ".", "$", "uriInfo", "[", "'filename'", "]", ")", "]", ";", "}" ]
Make an analize of the URI. Returns the output content type and the URI @return array
[ "Make", "an", "analize", "of", "the", "URI", ".", "Returns", "the", "output", "content", "type", "and", "the", "URI" ]
5cb07328f60887b551bf3d129439c6d05f6e4702
https://github.com/albertvision/MRestFramework/blob/5cb07328f60887b551bf3d129439c6d05f6e4702/src/Maleeby/MRest/Routing.php#L188-L200
401
albertvision/MRestFramework
src/Maleeby/MRest/Routing.php
Routing.fixUri
public static function fixUri($url) { $url = preg_replace('#/+|\\\+#', '/', $url); if ($url[0] == '/') { $url = substr($url, 1, strlen($url)); } if (substr($url, -1) == '/') { $url = substr($url, 0, strlen($url) - 1); } return $url; }
php
public static function fixUri($url) { $url = preg_replace('#/+|\\\+#', '/', $url); if ($url[0] == '/') { $url = substr($url, 1, strlen($url)); } if (substr($url, -1) == '/') { $url = substr($url, 0, strlen($url) - 1); } return $url; }
[ "public", "static", "function", "fixUri", "(", "$", "url", ")", "{", "$", "url", "=", "preg_replace", "(", "'#/+|\\\\\\+#'", ",", "'/'", ",", "$", "url", ")", ";", "if", "(", "$", "url", "[", "0", "]", "==", "'/'", ")", "{", "$", "url", "=", "substr", "(", "$", "url", ",", "1", ",", "strlen", "(", "$", "url", ")", ")", ";", "}", "if", "(", "substr", "(", "$", "url", ",", "-", "1", ")", "==", "'/'", ")", "{", "$", "url", "=", "substr", "(", "$", "url", ",", "0", ",", "strlen", "(", "$", "url", ")", "-", "1", ")", ";", "}", "return", "$", "url", ";", "}" ]
Fix the URI. Removes the multiple slashes @param string $url URI @return string The cleaned URI
[ "Fix", "the", "URI", ".", "Removes", "the", "multiple", "slashes" ]
5cb07328f60887b551bf3d129439c6d05f6e4702
https://github.com/albertvision/MRestFramework/blob/5cb07328f60887b551bf3d129439c6d05f6e4702/src/Maleeby/MRest/Routing.php#L208-L218
402
ntentan/utils
src/filesystem/Directory.php
Directory.directoryOperation
private function directoryOperation(string $operation, string $destination):void { try { Filesystem::checkExists($destination); } catch (FileNotFoundException $e) { $destinationDir = new self($destination); $destinationDir->create(); } $files = $this->getFiles(); foreach ($files as $file) { $destinationPath = "$destination/" . basename($file); $file->$operation($destinationPath); } }
php
private function directoryOperation(string $operation, string $destination):void { try { Filesystem::checkExists($destination); } catch (FileNotFoundException $e) { $destinationDir = new self($destination); $destinationDir->create(); } $files = $this->getFiles(); foreach ($files as $file) { $destinationPath = "$destination/" . basename($file); $file->$operation($destinationPath); } }
[ "private", "function", "directoryOperation", "(", "string", "$", "operation", ",", "string", "$", "destination", ")", ":", "void", "{", "try", "{", "Filesystem", "::", "checkExists", "(", "$", "destination", ")", ";", "}", "catch", "(", "FileNotFoundException", "$", "e", ")", "{", "$", "destinationDir", "=", "new", "self", "(", "$", "destination", ")", ";", "$", "destinationDir", "->", "create", "(", ")", ";", "}", "$", "files", "=", "$", "this", "->", "getFiles", "(", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "destinationPath", "=", "\"$destination/\"", ".", "basename", "(", "$", "file", ")", ";", "$", "file", "->", "$", "operation", "(", "$", "destinationPath", ")", ";", "}", "}" ]
Used to perform copies and moves. @param string $operation @param string $destination @throws FileNotFoundException @throws FilesystemException @throws \ntentan\utils\exceptions\FileAlreadyExistsException @throws \ntentan\utils\exceptions\FileNotReadableException @throws \ntentan\utils\exceptions\FileNotWriteableException
[ "Used", "to", "perform", "copies", "and", "moves", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/filesystem/Directory.php#L45-L59
403
ntentan/utils
src/filesystem/Directory.php
Directory.getSize
public function getSize() : int { $files = $this->getFiles(); $size = 0; foreach($files as $file) { $size += $file->getSize(); } return $size; }
php
public function getSize() : int { $files = $this->getFiles(); $size = 0; foreach($files as $file) { $size += $file->getSize(); } return $size; }
[ "public", "function", "getSize", "(", ")", ":", "int", "{", "$", "files", "=", "$", "this", "->", "getFiles", "(", ")", ";", "$", "size", "=", "0", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "size", "+=", "$", "file", "->", "getSize", "(", ")", ";", "}", "return", "$", "size", ";", "}" ]
Recursively get the size of all contents in the directory. @return integer @throws FileNotFoundException @throws FilesystemException @throws \ntentan\utils\exceptions\FileNotReadableException
[ "Recursively", "get", "the", "size", "of", "all", "contents", "in", "the", "directory", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/filesystem/Directory.php#L84-L92
404
ntentan/utils
src/filesystem/Directory.php
Directory.moveTo
public function moveTo(string $destination) : void { $this->directoryOperation('moveTo', $destination); $this->delete(); $this->path = $destination; }
php
public function moveTo(string $destination) : void { $this->directoryOperation('moveTo', $destination); $this->delete(); $this->path = $destination; }
[ "public", "function", "moveTo", "(", "string", "$", "destination", ")", ":", "void", "{", "$", "this", "->", "directoryOperation", "(", "'moveTo'", ",", "$", "destination", ")", ";", "$", "this", "->", "delete", "(", ")", ";", "$", "this", "->", "path", "=", "$", "destination", ";", "}" ]
Recursively move a directory and its contents to another location. @param string $destination @throws FileNotFoundException @throws FilesystemException @throws \ntentan\utils\exceptions\FileAlreadyExistsException @throws \ntentan\utils\exceptions\FileNotReadableException @throws \ntentan\utils\exceptions\FileNotWriteableException
[ "Recursively", "move", "a", "directory", "and", "its", "contents", "to", "another", "location", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/filesystem/Directory.php#L104-L109
405
ntentan/utils
src/filesystem/Directory.php
Directory.create
public function create($permissions = 0755) { Filesystem::checkNotExists($this->path); Filesystem::checkWritable(dirname($this->path)); mkdir($this->path, $permissions, true); }
php
public function create($permissions = 0755) { Filesystem::checkNotExists($this->path); Filesystem::checkWritable(dirname($this->path)); mkdir($this->path, $permissions, true); }
[ "public", "function", "create", "(", "$", "permissions", "=", "0755", ")", "{", "Filesystem", "::", "checkNotExists", "(", "$", "this", "->", "path", ")", ";", "Filesystem", "::", "checkWritable", "(", "dirname", "(", "$", "this", "->", "path", ")", ")", ";", "mkdir", "(", "$", "this", "->", "path", ",", "$", "permissions", ",", "true", ")", ";", "}" ]
Create the directory pointed to by path. @param int $permissions @throws \ntentan\utils\exceptions\FileAlreadyExistsException @throws \ntentan\utils\exceptions\FileNotWriteableException
[ "Create", "the", "directory", "pointed", "to", "by", "path", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/filesystem/Directory.php#L118-L123
406
ntentan/utils
src/filesystem/Directory.php
Directory.delete
public function delete() : void { $files = $this->getFiles(); foreach($files as $file) { $file->delete(); } rmdir($this->path); }
php
public function delete() : void { $files = $this->getFiles(); foreach($files as $file) { $file->delete(); } rmdir($this->path); }
[ "public", "function", "delete", "(", ")", ":", "void", "{", "$", "files", "=", "$", "this", "->", "getFiles", "(", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "file", "->", "delete", "(", ")", ";", "}", "rmdir", "(", "$", "this", "->", "path", ")", ";", "}" ]
Recursively delete the directory and all its contents. @throws FileNotFoundException @throws FilesystemException @throws \ntentan\utils\exceptions\FileNotReadableException
[ "Recursively", "delete", "the", "directory", "and", "all", "its", "contents", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/filesystem/Directory.php#L132-L139
407
ntentan/utils
src/filesystem/Directory.php
Directory.getFiles
public function getFiles() : array { Filesystem::checkExists($this->path); Filesystem::checkReadable($this->path); $contents = []; $files = scandir($this->path); foreach ($files as $file) { if($file != '.' && $file != '..') { $contents[] = Filesystem::get("$this->path/$file"); } } return $contents; }
php
public function getFiles() : array { Filesystem::checkExists($this->path); Filesystem::checkReadable($this->path); $contents = []; $files = scandir($this->path); foreach ($files as $file) { if($file != '.' && $file != '..') { $contents[] = Filesystem::get("$this->path/$file"); } } return $contents; }
[ "public", "function", "getFiles", "(", ")", ":", "array", "{", "Filesystem", "::", "checkExists", "(", "$", "this", "->", "path", ")", ";", "Filesystem", "::", "checkReadable", "(", "$", "this", "->", "path", ")", ";", "$", "contents", "=", "[", "]", ";", "$", "files", "=", "scandir", "(", "$", "this", "->", "path", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "$", "file", "!=", "'.'", "&&", "$", "file", "!=", "'..'", ")", "{", "$", "contents", "[", "]", "=", "Filesystem", "::", "get", "(", "\"$this->path/$file\"", ")", ";", "}", "}", "return", "$", "contents", ";", "}" ]
Get the files in the directory. @throws FilesystemException @throws \ntentan\utils\exceptions\FileNotFoundException @throws \ntentan\utils\exceptions\FileNotReadableException @return array<FileInterface>
[ "Get", "the", "files", "in", "the", "directory", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/filesystem/Directory.php#L159-L172
408
gosizzle/sizzle-php-sdk
src/ApiCall.php
ApiCall.curl
protected function curl($type, $endpoint, $variables) { $url = $this->baseUrl . '/' . $endpoint; $handle = curl_init(); curl_setopt($handle, CURLOPT_POST, true); //curl_setopt($handle, CURLOPT_COOKIE, TEST_COOKIE); $fieldsString = ""; foreach ($variables as $key=>$value) { $fieldsString .= $key.'='.$value.'&'; } $fieldsString = rtrim($fieldsString, '&'); curl_setopt($handle, CURLOPT_POSTFIELDS, $fieldsString); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($handle, CURLOPT_URL, $url); $response = curl_exec($handle); $statusCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); return array('statusCode'=>$statusCode, 'response'=>$response); }
php
protected function curl($type, $endpoint, $variables) { $url = $this->baseUrl . '/' . $endpoint; $handle = curl_init(); curl_setopt($handle, CURLOPT_POST, true); //curl_setopt($handle, CURLOPT_COOKIE, TEST_COOKIE); $fieldsString = ""; foreach ($variables as $key=>$value) { $fieldsString .= $key.'='.$value.'&'; } $fieldsString = rtrim($fieldsString, '&'); curl_setopt($handle, CURLOPT_POSTFIELDS, $fieldsString); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($handle, CURLOPT_URL, $url); $response = curl_exec($handle); $statusCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); return array('statusCode'=>$statusCode, 'response'=>$response); }
[ "protected", "function", "curl", "(", "$", "type", ",", "$", "endpoint", ",", "$", "variables", ")", "{", "$", "url", "=", "$", "this", "->", "baseUrl", ".", "'/'", ".", "$", "endpoint", ";", "$", "handle", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_POST", ",", "true", ")", ";", "//curl_setopt($handle, CURLOPT_COOKIE, TEST_COOKIE);", "$", "fieldsString", "=", "\"\"", ";", "foreach", "(", "$", "variables", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "fieldsString", ".=", "$", "key", ".", "'='", ".", "$", "value", ".", "'&'", ";", "}", "$", "fieldsString", "=", "rtrim", "(", "$", "fieldsString", ",", "'&'", ")", ";", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_POSTFIELDS", ",", "$", "fieldsString", ")", ";", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_URL", ",", "$", "url", ")", ";", "$", "response", "=", "curl_exec", "(", "$", "handle", ")", ";", "$", "statusCode", "=", "curl_getinfo", "(", "$", "handle", ",", "CURLINFO_HTTP_CODE", ")", ";", "return", "array", "(", "'statusCode'", "=>", "$", "statusCode", ",", "'response'", "=>", "$", "response", ")", ";", "}" ]
Curls the API with the desired request type. @param string $type - the type of curl request (DELETE, GET, POST, PUT) @param string $endpoint - the endpoint to hit @param array $variables - the variables to send @return string - API response (status code and string)
[ "Curls", "the", "API", "with", "the", "desired", "request", "type", "." ]
b9710d8c253e61edd76555765e7b9aa314dd5063
https://github.com/gosizzle/sizzle-php-sdk/blob/b9710d8c253e61edd76555765e7b9aa314dd5063/src/ApiCall.php#L80-L97
409
leodido/conversio
library/Adapter/Options/OptionsMap.php
OptionsMap.setOption
protected function setOption($key, $value) { if (!isset($this->config[$key])) { throw new Exception\DomainException( sprintf( 'Option "%s" does not exist; available options are (%s)', $key, implode( ', ', array_map( function ($opt) { return '"' . $opt . '"'; }, array_keys($this->config) ) ) ) ); } if (!ArrayUtils::isList($this->config[$key], false)) { throw new Exception\DomainException(sprintf( 'Option "%s" does not have a list of allowed values', $key )); } if (!ArrayUtils::inArray($value, $this->config[$key], true)) { throw new Exception\InvalidArgumentException(sprintf( 'Option "%s" can not be set to value "%s"; allowed values are (%s)', $key, $value, implode( ', ', array_map( function ($val) { return '"' . $val . '"'; }, $this->config[$key] ) ) )); } $this->options[$key] = $value; return $this; }
php
protected function setOption($key, $value) { if (!isset($this->config[$key])) { throw new Exception\DomainException( sprintf( 'Option "%s" does not exist; available options are (%s)', $key, implode( ', ', array_map( function ($opt) { return '"' . $opt . '"'; }, array_keys($this->config) ) ) ) ); } if (!ArrayUtils::isList($this->config[$key], false)) { throw new Exception\DomainException(sprintf( 'Option "%s" does not have a list of allowed values', $key )); } if (!ArrayUtils::inArray($value, $this->config[$key], true)) { throw new Exception\InvalidArgumentException(sprintf( 'Option "%s" can not be set to value "%s"; allowed values are (%s)', $key, $value, implode( ', ', array_map( function ($val) { return '"' . $val . '"'; }, $this->config[$key] ) ) )); } $this->options[$key] = $value; return $this; }
[ "protected", "function", "setOption", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "DomainException", "(", "sprintf", "(", "'Option \"%s\" does not exist; available options are (%s)'", ",", "$", "key", ",", "implode", "(", "', '", ",", "array_map", "(", "function", "(", "$", "opt", ")", "{", "return", "'\"'", ".", "$", "opt", ".", "'\"'", ";", "}", ",", "array_keys", "(", "$", "this", "->", "config", ")", ")", ")", ")", ")", ";", "}", "if", "(", "!", "ArrayUtils", "::", "isList", "(", "$", "this", "->", "config", "[", "$", "key", "]", ",", "false", ")", ")", "{", "throw", "new", "Exception", "\\", "DomainException", "(", "sprintf", "(", "'Option \"%s\" does not have a list of allowed values'", ",", "$", "key", ")", ")", ";", "}", "if", "(", "!", "ArrayUtils", "::", "inArray", "(", "$", "value", ",", "$", "this", "->", "config", "[", "$", "key", "]", ",", "true", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Option \"%s\" can not be set to value \"%s\"; allowed values are (%s)'", ",", "$", "key", ",", "$", "value", ",", "implode", "(", "', '", ",", "array_map", "(", "function", "(", "$", "val", ")", "{", "return", "'\"'", ".", "$", "val", ".", "'\"'", ";", "}", ",", "$", "this", "->", "config", "[", "$", "key", "]", ")", ")", ")", ")", ";", "}", "$", "this", "->", "options", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Option setter with validation If option can have the specified value then it is set, otherwise this method throws exception Tip: call it into your setter methods. @param $key @param $value @return $this @throws Exception\DomainException @throws Exception\InvalidArgumentException
[ "Option", "setter", "with", "validation", "If", "option", "can", "have", "the", "specified", "value", "then", "it", "is", "set", "otherwise", "this", "method", "throws", "exception" ]
ebbb626b0cf2a44729af6d46d753b5a4b06d9835
https://github.com/leodido/conversio/blob/ebbb626b0cf2a44729af6d46d753b5a4b06d9835/library/Adapter/Options/OptionsMap.php#L69-L112
410
leodido/conversio
library/Adapter/Options/OptionsMap.php
OptionsMap.getOption
protected function getOption($key) { if (!isset($this->options[$key])) { throw new Exception\RuntimeException(sprintf( 'Option "%s" not found', $key )); } return $this->options[$key]; }
php
protected function getOption($key) { if (!isset($this->options[$key])) { throw new Exception\RuntimeException(sprintf( 'Option "%s" not found', $key )); } return $this->options[$key]; }
[ "protected", "function", "getOption", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "sprintf", "(", "'Option \"%s\" not found'", ",", "$", "key", ")", ")", ";", "}", "return", "$", "this", "->", "options", "[", "$", "key", "]", ";", "}" ]
Option getter with check Tip: call it into your getter methods. @param $key @return mixed @throws Exception\RuntimeException
[ "Option", "getter", "with", "check" ]
ebbb626b0cf2a44729af6d46d753b5a4b06d9835
https://github.com/leodido/conversio/blob/ebbb626b0cf2a44729af6d46d753b5a4b06d9835/library/Adapter/Options/OptionsMap.php#L123-L133
411
bishopb/vanilla
library/core/class.thememanager.php
Gdn_ThemeManager.Start
public function Start($Force = FALSE) { if (function_exists('apc_fetch') && C('Garden.Apc', FALSE)) $this->Apc = TRUE; // Build list of all available themes $this->AvailableThemes($Force); // If there is a hooks file in the theme folder, include it. $ThemeName = $this->CurrentTheme(); $ThemeInfo = $this->GetThemeInfo($ThemeName); $ThemeHooks = GetValue('RealHooksFile', $ThemeInfo, NULL); if (file_exists($ThemeHooks)) include_once($ThemeHooks); }
php
public function Start($Force = FALSE) { if (function_exists('apc_fetch') && C('Garden.Apc', FALSE)) $this->Apc = TRUE; // Build list of all available themes $this->AvailableThemes($Force); // If there is a hooks file in the theme folder, include it. $ThemeName = $this->CurrentTheme(); $ThemeInfo = $this->GetThemeInfo($ThemeName); $ThemeHooks = GetValue('RealHooksFile', $ThemeInfo, NULL); if (file_exists($ThemeHooks)) include_once($ThemeHooks); }
[ "public", "function", "Start", "(", "$", "Force", "=", "FALSE", ")", "{", "if", "(", "function_exists", "(", "'apc_fetch'", ")", "&&", "C", "(", "'Garden.Apc'", ",", "FALSE", ")", ")", "$", "this", "->", "Apc", "=", "TRUE", ";", "// Build list of all available themes", "$", "this", "->", "AvailableThemes", "(", "$", "Force", ")", ";", "// If there is a hooks file in the theme folder, include it.", "$", "ThemeName", "=", "$", "this", "->", "CurrentTheme", "(", ")", ";", "$", "ThemeInfo", "=", "$", "this", "->", "GetThemeInfo", "(", "$", "ThemeName", ")", ";", "$", "ThemeHooks", "=", "GetValue", "(", "'RealHooksFile'", ",", "$", "ThemeInfo", ",", "NULL", ")", ";", "if", "(", "file_exists", "(", "$", "ThemeHooks", ")", ")", "include_once", "(", "$", "ThemeHooks", ")", ";", "}" ]
Sets up the theme framework This method indexes all available themes and extracts their information. It then determines which plugins have been enabled, and includes them. Finally, it parses all plugin files and extracts their events and plugged methods.
[ "Sets", "up", "the", "theme", "framework" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.thememanager.php#L49-L63
412
bishopb/vanilla
library/core/class.thememanager.php
Gdn_ThemeManager.AvailableThemes
public function AvailableThemes($Force = FALSE) { if (is_null($this->ThemeCache) || $Force) { $this->ThemeCache = array(); // Check cache freshness foreach ($this->SearchPaths() as $SearchPath => $Trash) { unset($SearchPathCache); // Check Cache $SearchPathCacheKey = 'Garden.Themes.PathCache.'.$SearchPath; if ($this->Apc) { $SearchPathCache = apc_fetch($SearchPathCacheKey); } else { $SearchPathCache = Gdn::Cache()->Get($SearchPathCacheKey, array(Gdn_Cache::FEATURE_NOPREFIX => TRUE)); } $CacheHit = ($SearchPathCache !== Gdn_Cache::CACHEOP_FAILURE); if ($CacheHit && is_array($SearchPathCache)) { $CacheIntegrityCheck = (sizeof(array_intersect(array_keys($SearchPathCache), array('CacheIntegrityHash', 'ThemeInfo'))) == 2); if (!$CacheIntegrityCheck) { $SearchPathCache = array( 'CacheIntegrityHash' => NULL, 'ThemeInfo' => array() ); } } $CacheThemeInfo = &$SearchPathCache['ThemeInfo']; if (!is_array($CacheThemeInfo)) $CacheThemeInfo = array(); $PathListing = scandir($SearchPath, 0); sort($PathListing); $PathIntegrityHash = md5(serialize($PathListing)); if (GetValue('CacheIntegrityHash',$SearchPathCache) != $PathIntegrityHash) { // Trace('Need to re-index theme cache'); // Need to re-index this folder $PathIntegrityHash = $this->IndexSearchPath($SearchPath, $CacheThemeInfo, $PathListing); if ($PathIntegrityHash === FALSE) continue; $SearchPathCache['CacheIntegrityHash'] = $PathIntegrityHash; if ($this->Apc) { apc_store($SearchPathCacheKey, $SearchPathCache); } else { Gdn::Cache()->Store($SearchPathCacheKey, $SearchPathCache, array(Gdn_Cache::FEATURE_NOPREFIX => TRUE)); } } $this->ThemeCache = array_merge($this->ThemeCache, $CacheThemeInfo); } } return $this->ThemeCache; }
php
public function AvailableThemes($Force = FALSE) { if (is_null($this->ThemeCache) || $Force) { $this->ThemeCache = array(); // Check cache freshness foreach ($this->SearchPaths() as $SearchPath => $Trash) { unset($SearchPathCache); // Check Cache $SearchPathCacheKey = 'Garden.Themes.PathCache.'.$SearchPath; if ($this->Apc) { $SearchPathCache = apc_fetch($SearchPathCacheKey); } else { $SearchPathCache = Gdn::Cache()->Get($SearchPathCacheKey, array(Gdn_Cache::FEATURE_NOPREFIX => TRUE)); } $CacheHit = ($SearchPathCache !== Gdn_Cache::CACHEOP_FAILURE); if ($CacheHit && is_array($SearchPathCache)) { $CacheIntegrityCheck = (sizeof(array_intersect(array_keys($SearchPathCache), array('CacheIntegrityHash', 'ThemeInfo'))) == 2); if (!$CacheIntegrityCheck) { $SearchPathCache = array( 'CacheIntegrityHash' => NULL, 'ThemeInfo' => array() ); } } $CacheThemeInfo = &$SearchPathCache['ThemeInfo']; if (!is_array($CacheThemeInfo)) $CacheThemeInfo = array(); $PathListing = scandir($SearchPath, 0); sort($PathListing); $PathIntegrityHash = md5(serialize($PathListing)); if (GetValue('CacheIntegrityHash',$SearchPathCache) != $PathIntegrityHash) { // Trace('Need to re-index theme cache'); // Need to re-index this folder $PathIntegrityHash = $this->IndexSearchPath($SearchPath, $CacheThemeInfo, $PathListing); if ($PathIntegrityHash === FALSE) continue; $SearchPathCache['CacheIntegrityHash'] = $PathIntegrityHash; if ($this->Apc) { apc_store($SearchPathCacheKey, $SearchPathCache); } else { Gdn::Cache()->Store($SearchPathCacheKey, $SearchPathCache, array(Gdn_Cache::FEATURE_NOPREFIX => TRUE)); } } $this->ThemeCache = array_merge($this->ThemeCache, $CacheThemeInfo); } } return $this->ThemeCache; }
[ "public", "function", "AvailableThemes", "(", "$", "Force", "=", "FALSE", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "ThemeCache", ")", "||", "$", "Force", ")", "{", "$", "this", "->", "ThemeCache", "=", "array", "(", ")", ";", "// Check cache freshness", "foreach", "(", "$", "this", "->", "SearchPaths", "(", ")", "as", "$", "SearchPath", "=>", "$", "Trash", ")", "{", "unset", "(", "$", "SearchPathCache", ")", ";", "// Check Cache", "$", "SearchPathCacheKey", "=", "'Garden.Themes.PathCache.'", ".", "$", "SearchPath", ";", "if", "(", "$", "this", "->", "Apc", ")", "{", "$", "SearchPathCache", "=", "apc_fetch", "(", "$", "SearchPathCacheKey", ")", ";", "}", "else", "{", "$", "SearchPathCache", "=", "Gdn", "::", "Cache", "(", ")", "->", "Get", "(", "$", "SearchPathCacheKey", ",", "array", "(", "Gdn_Cache", "::", "FEATURE_NOPREFIX", "=>", "TRUE", ")", ")", ";", "}", "$", "CacheHit", "=", "(", "$", "SearchPathCache", "!==", "Gdn_Cache", "::", "CACHEOP_FAILURE", ")", ";", "if", "(", "$", "CacheHit", "&&", "is_array", "(", "$", "SearchPathCache", ")", ")", "{", "$", "CacheIntegrityCheck", "=", "(", "sizeof", "(", "array_intersect", "(", "array_keys", "(", "$", "SearchPathCache", ")", ",", "array", "(", "'CacheIntegrityHash'", ",", "'ThemeInfo'", ")", ")", ")", "==", "2", ")", ";", "if", "(", "!", "$", "CacheIntegrityCheck", ")", "{", "$", "SearchPathCache", "=", "array", "(", "'CacheIntegrityHash'", "=>", "NULL", ",", "'ThemeInfo'", "=>", "array", "(", ")", ")", ";", "}", "}", "$", "CacheThemeInfo", "=", "&", "$", "SearchPathCache", "[", "'ThemeInfo'", "]", ";", "if", "(", "!", "is_array", "(", "$", "CacheThemeInfo", ")", ")", "$", "CacheThemeInfo", "=", "array", "(", ")", ";", "$", "PathListing", "=", "scandir", "(", "$", "SearchPath", ",", "0", ")", ";", "sort", "(", "$", "PathListing", ")", ";", "$", "PathIntegrityHash", "=", "md5", "(", "serialize", "(", "$", "PathListing", ")", ")", ";", "if", "(", "GetValue", "(", "'CacheIntegrityHash'", ",", "$", "SearchPathCache", ")", "!=", "$", "PathIntegrityHash", ")", "{", "// Trace('Need to re-index theme cache');", "// Need to re-index this folder", "$", "PathIntegrityHash", "=", "$", "this", "->", "IndexSearchPath", "(", "$", "SearchPath", ",", "$", "CacheThemeInfo", ",", "$", "PathListing", ")", ";", "if", "(", "$", "PathIntegrityHash", "===", "FALSE", ")", "continue", ";", "$", "SearchPathCache", "[", "'CacheIntegrityHash'", "]", "=", "$", "PathIntegrityHash", ";", "if", "(", "$", "this", "->", "Apc", ")", "{", "apc_store", "(", "$", "SearchPathCacheKey", ",", "$", "SearchPathCache", ")", ";", "}", "else", "{", "Gdn", "::", "Cache", "(", ")", "->", "Store", "(", "$", "SearchPathCacheKey", ",", "$", "SearchPathCache", ",", "array", "(", "Gdn_Cache", "::", "FEATURE_NOPREFIX", "=>", "TRUE", ")", ")", ";", "}", "}", "$", "this", "->", "ThemeCache", "=", "array_merge", "(", "$", "this", "->", "ThemeCache", ",", "$", "CacheThemeInfo", ")", ";", "}", "}", "return", "$", "this", "->", "ThemeCache", ";", "}" ]
Looks through the themes directory for valid themes and returns them as an associative array of "Theme Name" => "Theme Info Array". It also adds a "Folder" definition to the Theme Info Array for each.
[ "Looks", "through", "the", "themes", "directory", "for", "valid", "themes", "and", "returns", "them", "as", "an", "associative", "array", "of", "Theme", "Name", "=", ">", "Theme", "Info", "Array", ".", "It", "also", "adds", "a", "Folder", "definition", "to", "the", "Theme", "Info", "Array", "for", "each", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.thememanager.php#L70-L126
413
Sms-Gate/TurboSmsAdapter
src/Soap/TurboSmsSoapAdapter.php
TurboSmsSoapAdapter.getBalance
public function getBalance(): float { $this->authenticator->authenticate(); return (float) $this->soapClient->__soapCall('GetCreditBalance', []) ->GetCreditBalanceResult; }
php
public function getBalance(): float { $this->authenticator->authenticate(); return (float) $this->soapClient->__soapCall('GetCreditBalance', []) ->GetCreditBalanceResult; }
[ "public", "function", "getBalance", "(", ")", ":", "float", "{", "$", "this", "->", "authenticator", "->", "authenticate", "(", ")", ";", "return", "(", "float", ")", "$", "this", "->", "soapClient", "->", "__soapCall", "(", "'GetCreditBalance'", ",", "[", "]", ")", "->", "GetCreditBalanceResult", ";", "}" ]
Get the balance @return float
[ "Get", "the", "balance" ]
999c9b0e77dcde7d79f47a9e0b84282c231c8744
https://github.com/Sms-Gate/TurboSmsAdapter/blob/999c9b0e77dcde7d79f47a9e0b84282c231c8744/src/Soap/TurboSmsSoapAdapter.php#L109-L115
414
Sms-Gate/TurboSmsAdapter
src/Soap/TurboSmsSoapAdapter.php
TurboSmsSoapAdapter.tryResolveErrorReason
private function tryResolveErrorReason(string $message): string { $key = $this->responseParser->parse($message); if ($key === 'invalid_phone') { return ErrorReasons::INVALID_PHONE_NUMBER; } return ErrorReasons::UNKNOWN; }
php
private function tryResolveErrorReason(string $message): string { $key = $this->responseParser->parse($message); if ($key === 'invalid_phone') { return ErrorReasons::INVALID_PHONE_NUMBER; } return ErrorReasons::UNKNOWN; }
[ "private", "function", "tryResolveErrorReason", "(", "string", "$", "message", ")", ":", "string", "{", "$", "key", "=", "$", "this", "->", "responseParser", "->", "parse", "(", "$", "message", ")", ";", "if", "(", "$", "key", "===", "'invalid_phone'", ")", "{", "return", "ErrorReasons", "::", "INVALID_PHONE_NUMBER", ";", "}", "return", "ErrorReasons", "::", "UNKNOWN", ";", "}" ]
Try to resolve error reason @param string $message @return string
[ "Try", "to", "resolve", "error", "reason" ]
999c9b0e77dcde7d79f47a9e0b84282c231c8744
https://github.com/Sms-Gate/TurboSmsAdapter/blob/999c9b0e77dcde7d79f47a9e0b84282c231c8744/src/Soap/TurboSmsSoapAdapter.php#L124-L133
415
Sms-Gate/TurboSmsAdapter
src/Soap/TurboSmsSoapAdapter.php
TurboSmsSoapAdapter.processResultMessages
private function processResultMessages(Message $message, array $recipients, $resultMessages): ResultCollection { if (is_scalar($resultMessages)) { $key = $this->responseParser->parse($resultMessages); if ($key === 'signature_not_allowed') { throw new SenderNameNotAllowedException(sprintf( 'The signature (sender) "%s" not allowed.', $message->getSender() )); } elseif ($key === 'signature_invalid') { throw new InvalidSenderNameException(sprintf( 'Invalid signature (sender): %s', $message->getSender() )); } throw new SendSmsException(sprintf( 'Cannot resolve the error for sending SMS. Error: %s', $resultMessages )); } $sendResult = $resultMessages[0]; $sendResultKey = $this->responseParser->parse($sendResult); if ($sendResultKey === 'missing_required_parameters') { throw new MissingRequiredParameterException('Missing required parameters.'); } if ($sendResultKey !== 'success' && $sendResultKey !== 'fail') { throw new SendSmsException(sprintf( 'Fail send sms. Result messages: %s', json_encode($resultMessages) )); } array_shift($resultMessages); $resultData = []; foreach ($recipients as $recipient) { $messageId = array_shift($resultMessages); $success = preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/', $messageId); if ($success) { $resultData[] = Result::successfully($recipient, $messageId); } else { $reason = $this->tryResolveErrorReason($messageId); $resultData[] = Result::failed($recipient, new Error($reason, $messageId)); } } return new ResultCollection(...$resultData); }
php
private function processResultMessages(Message $message, array $recipients, $resultMessages): ResultCollection { if (is_scalar($resultMessages)) { $key = $this->responseParser->parse($resultMessages); if ($key === 'signature_not_allowed') { throw new SenderNameNotAllowedException(sprintf( 'The signature (sender) "%s" not allowed.', $message->getSender() )); } elseif ($key === 'signature_invalid') { throw new InvalidSenderNameException(sprintf( 'Invalid signature (sender): %s', $message->getSender() )); } throw new SendSmsException(sprintf( 'Cannot resolve the error for sending SMS. Error: %s', $resultMessages )); } $sendResult = $resultMessages[0]; $sendResultKey = $this->responseParser->parse($sendResult); if ($sendResultKey === 'missing_required_parameters') { throw new MissingRequiredParameterException('Missing required parameters.'); } if ($sendResultKey !== 'success' && $sendResultKey !== 'fail') { throw new SendSmsException(sprintf( 'Fail send sms. Result messages: %s', json_encode($resultMessages) )); } array_shift($resultMessages); $resultData = []; foreach ($recipients as $recipient) { $messageId = array_shift($resultMessages); $success = preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/', $messageId); if ($success) { $resultData[] = Result::successfully($recipient, $messageId); } else { $reason = $this->tryResolveErrorReason($messageId); $resultData[] = Result::failed($recipient, new Error($reason, $messageId)); } } return new ResultCollection(...$resultData); }
[ "private", "function", "processResultMessages", "(", "Message", "$", "message", ",", "array", "$", "recipients", ",", "$", "resultMessages", ")", ":", "ResultCollection", "{", "if", "(", "is_scalar", "(", "$", "resultMessages", ")", ")", "{", "$", "key", "=", "$", "this", "->", "responseParser", "->", "parse", "(", "$", "resultMessages", ")", ";", "if", "(", "$", "key", "===", "'signature_not_allowed'", ")", "{", "throw", "new", "SenderNameNotAllowedException", "(", "sprintf", "(", "'The signature (sender) \"%s\" not allowed.'", ",", "$", "message", "->", "getSender", "(", ")", ")", ")", ";", "}", "elseif", "(", "$", "key", "===", "'signature_invalid'", ")", "{", "throw", "new", "InvalidSenderNameException", "(", "sprintf", "(", "'Invalid signature (sender): %s'", ",", "$", "message", "->", "getSender", "(", ")", ")", ")", ";", "}", "throw", "new", "SendSmsException", "(", "sprintf", "(", "'Cannot resolve the error for sending SMS. Error: %s'", ",", "$", "resultMessages", ")", ")", ";", "}", "$", "sendResult", "=", "$", "resultMessages", "[", "0", "]", ";", "$", "sendResultKey", "=", "$", "this", "->", "responseParser", "->", "parse", "(", "$", "sendResult", ")", ";", "if", "(", "$", "sendResultKey", "===", "'missing_required_parameters'", ")", "{", "throw", "new", "MissingRequiredParameterException", "(", "'Missing required parameters.'", ")", ";", "}", "if", "(", "$", "sendResultKey", "!==", "'success'", "&&", "$", "sendResultKey", "!==", "'fail'", ")", "{", "throw", "new", "SendSmsException", "(", "sprintf", "(", "'Fail send sms. Result messages: %s'", ",", "json_encode", "(", "$", "resultMessages", ")", ")", ")", ";", "}", "array_shift", "(", "$", "resultMessages", ")", ";", "$", "resultData", "=", "[", "]", ";", "foreach", "(", "$", "recipients", "as", "$", "recipient", ")", "{", "$", "messageId", "=", "array_shift", "(", "$", "resultMessages", ")", ";", "$", "success", "=", "preg_match", "(", "'/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/'", ",", "$", "messageId", ")", ";", "if", "(", "$", "success", ")", "{", "$", "resultData", "[", "]", "=", "Result", "::", "successfully", "(", "$", "recipient", ",", "$", "messageId", ")", ";", "}", "else", "{", "$", "reason", "=", "$", "this", "->", "tryResolveErrorReason", "(", "$", "messageId", ")", ";", "$", "resultData", "[", "]", "=", "Result", "::", "failed", "(", "$", "recipient", ",", "new", "Error", "(", "$", "reason", ",", "$", "messageId", ")", ")", ";", "}", "}", "return", "new", "ResultCollection", "(", "...", "$", "resultData", ")", ";", "}" ]
Process the response from TurboSMS @param Message $message @param Phone[] $recipients @param string|array $resultMessages @return ResultCollection @throws \Exception
[ "Process", "the", "response", "from", "TurboSMS" ]
999c9b0e77dcde7d79f47a9e0b84282c231c8744
https://github.com/Sms-Gate/TurboSmsAdapter/blob/999c9b0e77dcde7d79f47a9e0b84282c231c8744/src/Soap/TurboSmsSoapAdapter.php#L146-L200
416
alxmsl/Network
source/Http/CurlTransport.php
CurlTransport.makeHttpRequest
public function makeHttpRequest() { $url = $this->addUrlData($this->Request->getUrl(), $this->Request->getUrlData()); $url = $this->addGetData($url, $this->Request->getGetData()); $Resource = curl_init($url); $options = [ CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => $this->Request->getConnectTimeout(), CURLOPT_TIMEOUT => $this->Request->getTimeout(), CURLOPT_HEADER => true, ]; if (!$this->Request->isDefaultSslVersion()) { $options[CURLOPT_SSLVERSION] = $this->Request->getSslVersion(); } curl_setopt_array($Resource, $this->getOptions() + $options); $this->addHeaders($Resource, $this->Request->getHeaders()); $this->addPostData($Resource, $this->Request->getPostData()); $this->setMethod($Resource, $this->Request->getMethod()); $result = curl_exec($Resource); if ($result === false) { $errorCode = curl_errno($Resource); $errorMessage = curl_error($Resource); curl_close($Resource); throw new CurlErrorException($errorMessage, $errorCode); } $headerSize = curl_getinfo($Resource, CURLINFO_HEADER_SIZE); $headers = substr($result, 0, $headerSize); $this->parseResponseHeaders($headers); $body = substr($result, $headerSize); $httpCode = curl_getinfo($Resource, CURLINFO_HTTP_CODE); curl_close($Resource); switch (floor($httpCode / 100)) { case 1: throw new HttpInformationalCodeException($body, $httpCode); case 3: throw new HttpRedirectionCodeException($body, $httpCode); case 4: throw new HttpClientErrorCodeException($body, $httpCode); case 5: throw new HttpServerErrorCodeException($body, $httpCode); default: case 2: return $body; } }
php
public function makeHttpRequest() { $url = $this->addUrlData($this->Request->getUrl(), $this->Request->getUrlData()); $url = $this->addGetData($url, $this->Request->getGetData()); $Resource = curl_init($url); $options = [ CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => $this->Request->getConnectTimeout(), CURLOPT_TIMEOUT => $this->Request->getTimeout(), CURLOPT_HEADER => true, ]; if (!$this->Request->isDefaultSslVersion()) { $options[CURLOPT_SSLVERSION] = $this->Request->getSslVersion(); } curl_setopt_array($Resource, $this->getOptions() + $options); $this->addHeaders($Resource, $this->Request->getHeaders()); $this->addPostData($Resource, $this->Request->getPostData()); $this->setMethod($Resource, $this->Request->getMethod()); $result = curl_exec($Resource); if ($result === false) { $errorCode = curl_errno($Resource); $errorMessage = curl_error($Resource); curl_close($Resource); throw new CurlErrorException($errorMessage, $errorCode); } $headerSize = curl_getinfo($Resource, CURLINFO_HEADER_SIZE); $headers = substr($result, 0, $headerSize); $this->parseResponseHeaders($headers); $body = substr($result, $headerSize); $httpCode = curl_getinfo($Resource, CURLINFO_HTTP_CODE); curl_close($Resource); switch (floor($httpCode / 100)) { case 1: throw new HttpInformationalCodeException($body, $httpCode); case 3: throw new HttpRedirectionCodeException($body, $httpCode); case 4: throw new HttpClientErrorCodeException($body, $httpCode); case 5: throw new HttpServerErrorCodeException($body, $httpCode); default: case 2: return $body; } }
[ "public", "function", "makeHttpRequest", "(", ")", "{", "$", "url", "=", "$", "this", "->", "addUrlData", "(", "$", "this", "->", "Request", "->", "getUrl", "(", ")", ",", "$", "this", "->", "Request", "->", "getUrlData", "(", ")", ")", ";", "$", "url", "=", "$", "this", "->", "addGetData", "(", "$", "url", ",", "$", "this", "->", "Request", "->", "getGetData", "(", ")", ")", ";", "$", "Resource", "=", "curl_init", "(", "$", "url", ")", ";", "$", "options", "=", "[", "CURLOPT_RETURNTRANSFER", "=>", "true", ",", "CURLOPT_CONNECTTIMEOUT", "=>", "$", "this", "->", "Request", "->", "getConnectTimeout", "(", ")", ",", "CURLOPT_TIMEOUT", "=>", "$", "this", "->", "Request", "->", "getTimeout", "(", ")", ",", "CURLOPT_HEADER", "=>", "true", ",", "]", ";", "if", "(", "!", "$", "this", "->", "Request", "->", "isDefaultSslVersion", "(", ")", ")", "{", "$", "options", "[", "CURLOPT_SSLVERSION", "]", "=", "$", "this", "->", "Request", "->", "getSslVersion", "(", ")", ";", "}", "curl_setopt_array", "(", "$", "Resource", ",", "$", "this", "->", "getOptions", "(", ")", "+", "$", "options", ")", ";", "$", "this", "->", "addHeaders", "(", "$", "Resource", ",", "$", "this", "->", "Request", "->", "getHeaders", "(", ")", ")", ";", "$", "this", "->", "addPostData", "(", "$", "Resource", ",", "$", "this", "->", "Request", "->", "getPostData", "(", ")", ")", ";", "$", "this", "->", "setMethod", "(", "$", "Resource", ",", "$", "this", "->", "Request", "->", "getMethod", "(", ")", ")", ";", "$", "result", "=", "curl_exec", "(", "$", "Resource", ")", ";", "if", "(", "$", "result", "===", "false", ")", "{", "$", "errorCode", "=", "curl_errno", "(", "$", "Resource", ")", ";", "$", "errorMessage", "=", "curl_error", "(", "$", "Resource", ")", ";", "curl_close", "(", "$", "Resource", ")", ";", "throw", "new", "CurlErrorException", "(", "$", "errorMessage", ",", "$", "errorCode", ")", ";", "}", "$", "headerSize", "=", "curl_getinfo", "(", "$", "Resource", ",", "CURLINFO_HEADER_SIZE", ")", ";", "$", "headers", "=", "substr", "(", "$", "result", ",", "0", ",", "$", "headerSize", ")", ";", "$", "this", "->", "parseResponseHeaders", "(", "$", "headers", ")", ";", "$", "body", "=", "substr", "(", "$", "result", ",", "$", "headerSize", ")", ";", "$", "httpCode", "=", "curl_getinfo", "(", "$", "Resource", ",", "CURLINFO_HTTP_CODE", ")", ";", "curl_close", "(", "$", "Resource", ")", ";", "switch", "(", "floor", "(", "$", "httpCode", "/", "100", ")", ")", "{", "case", "1", ":", "throw", "new", "HttpInformationalCodeException", "(", "$", "body", ",", "$", "httpCode", ")", ";", "case", "3", ":", "throw", "new", "HttpRedirectionCodeException", "(", "$", "body", ",", "$", "httpCode", ")", ";", "case", "4", ":", "throw", "new", "HttpClientErrorCodeException", "(", "$", "body", ",", "$", "httpCode", ")", ";", "case", "5", ":", "throw", "new", "HttpServerErrorCodeException", "(", "$", "body", ",", "$", "httpCode", ")", ";", "default", ":", "case", "2", ":", "return", "$", "body", ";", "}", "}" ]
Transportation implementation method @return string request execution result @throws HttpRedirectionCodeException if http redirect code accepted @throws HttpClientErrorCodeException if http client error code accepted @throws HttpInformationalCodeException if http information code accepted @throws HttpServerErrorCodeException if http server error code accepted @throws CurlErrorException if libcurl error generated
[ "Transportation", "implementation", "method" ]
5c5b058572885303ff44f310bc7bedad683ca8c1
https://github.com/alxmsl/Network/blob/5c5b058572885303ff44f310bc7bedad683ca8c1/source/Http/CurlTransport.php#L76-L124
417
alxmsl/Network
source/Http/CurlTransport.php
CurlTransport.parseResponseHeaders
private function parseResponseHeaders($string) { $parts = explode("\n", $string); foreach ($parts as $part) { if (strpos($part, ':') !== false) { list($name, $value) = explode(':', $part); $this->responseHeaders[trim($name)] = trim($value); } } }
php
private function parseResponseHeaders($string) { $parts = explode("\n", $string); foreach ($parts as $part) { if (strpos($part, ':') !== false) { list($name, $value) = explode(':', $part); $this->responseHeaders[trim($name)] = trim($value); } } }
[ "private", "function", "parseResponseHeaders", "(", "$", "string", ")", "{", "$", "parts", "=", "explode", "(", "\"\\n\"", ",", "$", "string", ")", ";", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "if", "(", "strpos", "(", "$", "part", ",", "':'", ")", "!==", "false", ")", "{", "list", "(", "$", "name", ",", "$", "value", ")", "=", "explode", "(", "':'", ",", "$", "part", ")", ";", "$", "this", "->", "responseHeaders", "[", "trim", "(", "$", "name", ")", "]", "=", "trim", "(", "$", "value", ")", ";", "}", "}", "}" ]
Parsing response block for headers @param string $string response block
[ "Parsing", "response", "block", "for", "headers" ]
5c5b058572885303ff44f310bc7bedad683ca8c1
https://github.com/alxmsl/Network/blob/5c5b058572885303ff44f310bc7bedad683ca8c1/source/Http/CurlTransport.php#L147-L155
418
alxmsl/Network
source/Http/CurlTransport.php
CurlTransport.addHeaders
private function addHeaders($Resource, $headers) { $httpHeaders = array(); foreach ($headers as $header => $value) { $httpHeaders[] = $header . ': ' . $value; } curl_setopt($Resource, CURLOPT_HTTPHEADER, $httpHeaders); }
php
private function addHeaders($Resource, $headers) { $httpHeaders = array(); foreach ($headers as $header => $value) { $httpHeaders[] = $header . ': ' . $value; } curl_setopt($Resource, CURLOPT_HTTPHEADER, $httpHeaders); }
[ "private", "function", "addHeaders", "(", "$", "Resource", ",", "$", "headers", ")", "{", "$", "httpHeaders", "=", "array", "(", ")", ";", "foreach", "(", "$", "headers", "as", "$", "header", "=>", "$", "value", ")", "{", "$", "httpHeaders", "[", "]", "=", "$", "header", ".", "': '", ".", "$", "value", ";", "}", "curl_setopt", "(", "$", "Resource", ",", "CURLOPT_HTTPHEADER", ",", "$", "httpHeaders", ")", ";", "}" ]
Add http headers method @param resource $Resource libcurl handler @param array $headers assotiative array of http headers and values
[ "Add", "http", "headers", "method" ]
5c5b058572885303ff44f310bc7bedad683ca8c1
https://github.com/alxmsl/Network/blob/5c5b058572885303ff44f310bc7bedad683ca8c1/source/Http/CurlTransport.php#L162-L168
419
alxmsl/Network
source/Http/CurlTransport.php
CurlTransport.addGetData
private function addGetData($url, $data) { $parts[] = $url; if (!empty($data)) { $parts[] = http_build_query($data); } return implode('?', $parts); }
php
private function addGetData($url, $data) { $parts[] = $url; if (!empty($data)) { $parts[] = http_build_query($data); } return implode('?', $parts); }
[ "private", "function", "addGetData", "(", "$", "url", ",", "$", "data", ")", "{", "$", "parts", "[", "]", "=", "$", "url", ";", "if", "(", "!", "empty", "(", "$", "data", ")", ")", "{", "$", "parts", "[", "]", "=", "http_build_query", "(", "$", "data", ")", ";", "}", "return", "implode", "(", "'?'", ",", "$", "parts", ")", ";", "}" ]
Add GET data for resource @param string $url resource url @param array $data GET parameters @return string query string
[ "Add", "GET", "data", "for", "resource" ]
5c5b058572885303ff44f310bc7bedad683ca8c1
https://github.com/alxmsl/Network/blob/5c5b058572885303ff44f310bc7bedad683ca8c1/source/Http/CurlTransport.php#L176-L182
420
alxmsl/Network
source/Http/CurlTransport.php
CurlTransport.addPostData
private function addPostData($Resource, $data) { if (!empty($data)) { switch ($this->Request->getContentTypeCode()) { case Request::CONTENT_TYPE_UNDEFINED: $string = http_build_query($data); break; case Request::CONTENT_TYPE_JSON: $string = json_encode($data); break; case Request::CONTENT_TYPE_TEXT: $string = (string) $data; break; case Request::CONTENT_TYPE_XML: if ($data instanceof DOMDocument) { $string = $data->saveXML(); } else { $string = (string) $data; } break; default: throw new HttpContentTypeException(); } curl_setopt_array($Resource, array( CURLOPT_POST => true, CURLOPT_POSTFIELDS => $string, )); } }
php
private function addPostData($Resource, $data) { if (!empty($data)) { switch ($this->Request->getContentTypeCode()) { case Request::CONTENT_TYPE_UNDEFINED: $string = http_build_query($data); break; case Request::CONTENT_TYPE_JSON: $string = json_encode($data); break; case Request::CONTENT_TYPE_TEXT: $string = (string) $data; break; case Request::CONTENT_TYPE_XML: if ($data instanceof DOMDocument) { $string = $data->saveXML(); } else { $string = (string) $data; } break; default: throw new HttpContentTypeException(); } curl_setopt_array($Resource, array( CURLOPT_POST => true, CURLOPT_POSTFIELDS => $string, )); } }
[ "private", "function", "addPostData", "(", "$", "Resource", ",", "$", "data", ")", "{", "if", "(", "!", "empty", "(", "$", "data", ")", ")", "{", "switch", "(", "$", "this", "->", "Request", "->", "getContentTypeCode", "(", ")", ")", "{", "case", "Request", "::", "CONTENT_TYPE_UNDEFINED", ":", "$", "string", "=", "http_build_query", "(", "$", "data", ")", ";", "break", ";", "case", "Request", "::", "CONTENT_TYPE_JSON", ":", "$", "string", "=", "json_encode", "(", "$", "data", ")", ";", "break", ";", "case", "Request", "::", "CONTENT_TYPE_TEXT", ":", "$", "string", "=", "(", "string", ")", "$", "data", ";", "break", ";", "case", "Request", "::", "CONTENT_TYPE_XML", ":", "if", "(", "$", "data", "instanceof", "DOMDocument", ")", "{", "$", "string", "=", "$", "data", "->", "saveXML", "(", ")", ";", "}", "else", "{", "$", "string", "=", "(", "string", ")", "$", "data", ";", "}", "break", ";", "default", ":", "throw", "new", "HttpContentTypeException", "(", ")", ";", "}", "curl_setopt_array", "(", "$", "Resource", ",", "array", "(", "CURLOPT_POST", "=>", "true", ",", "CURLOPT_POSTFIELDS", "=>", "$", "string", ",", ")", ")", ";", "}", "}" ]
Add POST data for request @param resource $Resource libcurl handler @param mixed $data POST parameters @throws HttpContentTypeException when use unsupported type of content
[ "Add", "POST", "data", "for", "request" ]
5c5b058572885303ff44f310bc7bedad683ca8c1
https://github.com/alxmsl/Network/blob/5c5b058572885303ff44f310bc7bedad683ca8c1/source/Http/CurlTransport.php#L190-L217
421
alxmsl/Network
source/Http/CurlTransport.php
CurlTransport.addUrlData
private function addUrlData($url, array $data) { // Do nothing, if there is no url data if (empty($data)) { return $url; } if (strpos($url, '?') !== false) { throw new \InvalidArgumentException(); } $parts[] = trim($url, '/'); foreach ($data as $key => $value) { if ($value) { $parts[] = urlencode($key) .'/' . urlencode($value); } else { $parts[] = urlencode($key); } } return implode('/', $parts); }
php
private function addUrlData($url, array $data) { // Do nothing, if there is no url data if (empty($data)) { return $url; } if (strpos($url, '?') !== false) { throw new \InvalidArgumentException(); } $parts[] = trim($url, '/'); foreach ($data as $key => $value) { if ($value) { $parts[] = urlencode($key) .'/' . urlencode($value); } else { $parts[] = urlencode($key); } } return implode('/', $parts); }
[ "private", "function", "addUrlData", "(", "$", "url", ",", "array", "$", "data", ")", "{", "// Do nothing, if there is no url data", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "$", "url", ";", "}", "if", "(", "strpos", "(", "$", "url", ",", "'?'", ")", "!==", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", ")", ";", "}", "$", "parts", "[", "]", "=", "trim", "(", "$", "url", ",", "'/'", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "$", "parts", "[", "]", "=", "urlencode", "(", "$", "key", ")", ".", "'/'", ".", "urlencode", "(", "$", "value", ")", ";", "}", "else", "{", "$", "parts", "[", "]", "=", "urlencode", "(", "$", "key", ")", ";", "}", "}", "return", "implode", "(", "'/'", ",", "$", "parts", ")", ";", "}" ]
Add url parameters for url @param string $url base url @param array $data url parameters key-value data @throws \InvalidArgumentException when url already contains GET data @return string query string
[ "Add", "url", "parameters", "for", "url" ]
5c5b058572885303ff44f310bc7bedad683ca8c1
https://github.com/alxmsl/Network/blob/5c5b058572885303ff44f310bc7bedad683ca8c1/source/Http/CurlTransport.php#L226-L245
422
alxmsl/Network
source/Http/CurlTransport.php
CurlTransport.setMethod
private function setMethod($Resource, $method) { switch ($method) { case Request::METHOD_GET: curl_setopt($Resource, CURLOPT_HTTPGET, true); break; case Request::METHOD_POST: curl_setopt($Resource, CURLOPT_POST, true); break; } }
php
private function setMethod($Resource, $method) { switch ($method) { case Request::METHOD_GET: curl_setopt($Resource, CURLOPT_HTTPGET, true); break; case Request::METHOD_POST: curl_setopt($Resource, CURLOPT_POST, true); break; } }
[ "private", "function", "setMethod", "(", "$", "Resource", ",", "$", "method", ")", "{", "switch", "(", "$", "method", ")", "{", "case", "Request", "::", "METHOD_GET", ":", "curl_setopt", "(", "$", "Resource", ",", "CURLOPT_HTTPGET", ",", "true", ")", ";", "break", ";", "case", "Request", "::", "METHOD_POST", ":", "curl_setopt", "(", "$", "Resource", ",", "CURLOPT_POST", ",", "true", ")", ";", "break", ";", "}", "}" ]
Set request HTTP method @param resource $Resource libcurl handler @param int $method HTTP method identifier
[ "Set", "request", "HTTP", "method" ]
5c5b058572885303ff44f310bc7bedad683ca8c1
https://github.com/alxmsl/Network/blob/5c5b058572885303ff44f310bc7bedad683ca8c1/source/Http/CurlTransport.php#L252-L261
423
loevgaard/pakkelabels-php-sdk
src/Client.php
Client.getPageCount
public function getPageCount() : int { if($this->lastResponse && $this->lastResponse->getHeaderLine('X-Total-Pages')) { return (int)$this->lastResponse->getHeaderLine('X-Total-Pages'); } return 0; }
php
public function getPageCount() : int { if($this->lastResponse && $this->lastResponse->getHeaderLine('X-Total-Pages')) { return (int)$this->lastResponse->getHeaderLine('X-Total-Pages'); } return 0; }
[ "public", "function", "getPageCount", "(", ")", ":", "int", "{", "if", "(", "$", "this", "->", "lastResponse", "&&", "$", "this", "->", "lastResponse", "->", "getHeaderLine", "(", "'X-Total-Pages'", ")", ")", "{", "return", "(", "int", ")", "$", "this", "->", "lastResponse", "->", "getHeaderLine", "(", "'X-Total-Pages'", ")", ";", "}", "return", "0", ";", "}" ]
Returns the number of pages in the collection Returns 0 if the header isn't set @return int
[ "Returns", "the", "number", "of", "pages", "in", "the", "collection", "Returns", "0", "if", "the", "header", "isn", "t", "set" ]
9817d0417f382c225a87ea71b8bd34e209aae3b4
https://github.com/loevgaard/pakkelabels-php-sdk/blob/9817d0417f382c225a87ea71b8bd34e209aae3b4/src/Client.php#L88-L95
424
loevgaard/pakkelabels-php-sdk
src/Client.php
Client.getItemCount
public function getItemCount() : int { if($this->lastResponse && $this->lastResponse->getHeaderLine('X-Total-Count')) { return (int)$this->lastResponse->getHeaderLine('X-Total-Count'); } return 0; }
php
public function getItemCount() : int { if($this->lastResponse && $this->lastResponse->getHeaderLine('X-Total-Count')) { return (int)$this->lastResponse->getHeaderLine('X-Total-Count'); } return 0; }
[ "public", "function", "getItemCount", "(", ")", ":", "int", "{", "if", "(", "$", "this", "->", "lastResponse", "&&", "$", "this", "->", "lastResponse", "->", "getHeaderLine", "(", "'X-Total-Count'", ")", ")", "{", "return", "(", "int", ")", "$", "this", "->", "lastResponse", "->", "getHeaderLine", "(", "'X-Total-Count'", ")", ";", "}", "return", "0", ";", "}" ]
Returns the total item count in the collection Returns 0 if the header isn't set @return int
[ "Returns", "the", "total", "item", "count", "in", "the", "collection", "Returns", "0", "if", "the", "header", "isn", "t", "set" ]
9817d0417f382c225a87ea71b8bd34e209aae3b4
https://github.com/loevgaard/pakkelabels-php-sdk/blob/9817d0417f382c225a87ea71b8bd34e209aae3b4/src/Client.php#L103-L110
425
gregoriohc/argentum-common
src/Common/Item.php
Item.setTaxes
public function setTaxes($value) { if (is_array($value)) { $bag = new Bag(); foreach ($value as $taxParameters) { $bag->add(new Tax($taxParameters)); } $value = $bag; } return $this->setParameter('taxes', $value); }
php
public function setTaxes($value) { if (is_array($value)) { $bag = new Bag(); foreach ($value as $taxParameters) { $bag->add(new Tax($taxParameters)); } $value = $bag; } return $this->setParameter('taxes', $value); }
[ "public", "function", "setTaxes", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "bag", "=", "new", "Bag", "(", ")", ";", "foreach", "(", "$", "value", "as", "$", "taxParameters", ")", "{", "$", "bag", "->", "add", "(", "new", "Tax", "(", "$", "taxParameters", ")", ")", ";", "}", "$", "value", "=", "$", "bag", ";", "}", "return", "$", "this", "->", "setParameter", "(", "'taxes'", ",", "$", "value", ")", ";", "}" ]
Set the item taxes @param Bag $value @return Item
[ "Set", "the", "item", "taxes" ]
9d914d19aa6ed25d33f00d603eff486484f0f3ba
https://github.com/gregoriohc/argentum-common/blob/9d914d19aa6ed25d33f00d603eff486484f0f3ba/src/Common/Item.php#L238-L249
426
Innmind/Reflection
src/ReflectionObject.php
ReflectionObject.withProperty
public function withProperty(string $name, $value): self { return new self( $this->object, $this->properties->put($name, $value), $this->injectionStrategy, $this->extractionStrategy ); }
php
public function withProperty(string $name, $value): self { return new self( $this->object, $this->properties->put($name, $value), $this->injectionStrategy, $this->extractionStrategy ); }
[ "public", "function", "withProperty", "(", "string", "$", "name", ",", "$", "value", ")", ":", "self", "{", "return", "new", "self", "(", "$", "this", "->", "object", ",", "$", "this", "->", "properties", "->", "put", "(", "$", "name", ",", "$", "value", ")", ",", "$", "this", "->", "injectionStrategy", ",", "$", "this", "->", "extractionStrategy", ")", ";", "}" ]
Add a property that will be injected @param mixed $value
[ "Add", "a", "property", "that", "will", "be", "injected" ]
b404ce0a91e24d83be6f3d44d51c869067e74a48
https://github.com/Innmind/Reflection/blob/b404ce0a91e24d83be6f3d44d51c869067e74a48/src/ReflectionObject.php#L58-L66
427
Innmind/Reflection
src/ReflectionObject.php
ReflectionObject.build
public function build(): object { return $this->properties->reduce( $this->object, function(object $object, string $key, $value): object { return $this->inject($object, $key, $value); } ); }
php
public function build(): object { return $this->properties->reduce( $this->object, function(object $object, string $key, $value): object { return $this->inject($object, $key, $value); } ); }
[ "public", "function", "build", "(", ")", ":", "object", "{", "return", "$", "this", "->", "properties", "->", "reduce", "(", "$", "this", "->", "object", ",", "function", "(", "object", "$", "object", ",", "string", "$", "key", ",", "$", "value", ")", ":", "object", "{", "return", "$", "this", "->", "inject", "(", "$", "object", ",", "$", "key", ",", "$", "value", ")", ";", "}", ")", ";", "}" ]
Return the object with the list of properties set on it
[ "Return", "the", "object", "with", "the", "list", "of", "properties", "set", "on", "it" ]
b404ce0a91e24d83be6f3d44d51c869067e74a48
https://github.com/Innmind/Reflection/blob/b404ce0a91e24d83be6f3d44d51c869067e74a48/src/ReflectionObject.php#L94-L102
428
Innmind/Reflection
src/ReflectionObject.php
ReflectionObject.extract
public function extract(string ...$properties): MapInterface { $map = new Map('string', 'mixed'); foreach ($properties as $property) { $map = $map->put( $property, $this->extractProperty($property) ); } return $map; }
php
public function extract(string ...$properties): MapInterface { $map = new Map('string', 'mixed'); foreach ($properties as $property) { $map = $map->put( $property, $this->extractProperty($property) ); } return $map; }
[ "public", "function", "extract", "(", "string", "...", "$", "properties", ")", ":", "MapInterface", "{", "$", "map", "=", "new", "Map", "(", "'string'", ",", "'mixed'", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "map", "=", "$", "map", "->", "put", "(", "$", "property", ",", "$", "this", "->", "extractProperty", "(", "$", "property", ")", ")", ";", "}", "return", "$", "map", ";", "}" ]
Extract the given list of properties @return MapInterface<string, mixed>
[ "Extract", "the", "given", "list", "of", "properties" ]
b404ce0a91e24d83be6f3d44d51c869067e74a48
https://github.com/Innmind/Reflection/blob/b404ce0a91e24d83be6f3d44d51c869067e74a48/src/ReflectionObject.php#L109-L121
429
alxmsl/Connection
source/Redis/Connection.php
Connection.getRedis
private function getRedis() { if (is_null($this->Redis)) { if ($this->isConfigured()) { $this->Redis = new \Redis(); $this->connect(); } else { throw new RedisNotConfiguredException(); } } return $this->Redis; }
php
private function getRedis() { if (is_null($this->Redis)) { if ($this->isConfigured()) { $this->Redis = new \Redis(); $this->connect(); } else { throw new RedisNotConfiguredException(); } } return $this->Redis; }
[ "private", "function", "getRedis", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "Redis", ")", ")", "{", "if", "(", "$", "this", "->", "isConfigured", "(", ")", ")", "{", "$", "this", "->", "Redis", "=", "new", "\\", "Redis", "(", ")", ";", "$", "this", "->", "connect", "(", ")", ";", "}", "else", "{", "throw", "new", "RedisNotConfiguredException", "(", ")", ";", "}", "}", "return", "$", "this", "->", "Redis", ";", "}" ]
Getter of phpredis object @return \Redis phpredis object instance @throws RedisNotConfiguredException if any of required redis connect parameters are loose
[ "Getter", "of", "phpredis", "object" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L46-L56
430
alxmsl/Connection
source/Redis/Connection.php
Connection.incr
public function incr($key, $value = 1) { $value = (int) $value; try { $result = ($value > 1) ? $this->getRedis()->incrBy($key, $value) : $this->getRedis()->incr($key); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function incr($key, $value = 1) { $value = (int) $value; try { $result = ($value > 1) ? $this->getRedis()->incrBy($key, $value) : $this->getRedis()->incr($key); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "incr", "(", "$", "key", ",", "$", "value", "=", "1", ")", "{", "$", "value", "=", "(", "int", ")", "$", "value", ";", "try", "{", "$", "result", "=", "(", "$", "value", ">", "1", ")", "?", "$", "this", "->", "getRedis", "(", ")", "->", "incrBy", "(", "$", "key", ",", "$", "value", ")", ":", "$", "this", "->", "getRedis", "(", ")", "->", "incr", "(", "$", "key", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "throw", "new", "ImpossibleValueException", "(", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Increment key value @param string $key key @param int $value value for increment @return int current value @throws ConnectException exception on connection to redis instance
[ "Increment", "key", "value" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L108-L121
431
alxmsl/Connection
source/Redis/Connection.php
Connection.decr
public function decr($key, $value = 1) { $value = (int) $value; try { $result = ($value > 1) ? $this->getRedis()->decrBy($key, $value) : $this->getRedis()->decr($key); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function decr($key, $value = 1) { $value = (int) $value; try { $result = ($value > 1) ? $this->getRedis()->decrBy($key, $value) : $this->getRedis()->decr($key); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "decr", "(", "$", "key", ",", "$", "value", "=", "1", ")", "{", "$", "value", "=", "(", "int", ")", "$", "value", ";", "try", "{", "$", "result", "=", "(", "$", "value", ">", "1", ")", "?", "$", "this", "->", "getRedis", "(", ")", "->", "decrBy", "(", "$", "key", ",", "$", "value", ")", ":", "$", "this", "->", "getRedis", "(", ")", "->", "decr", "(", "$", "key", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "throw", "new", "ImpossibleValueException", "(", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Decrement key value @param string $key key @param int $value value for increment @return int current value @throws ConnectException exception on connection to redis instance
[ "Decrement", "key", "value" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L130-L143
432
alxmsl/Connection
source/Redis/Connection.php
Connection.append
public function append($key, $value) { try { $result = $this->getRedis()->append($key, $value); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function append($key, $value) { try { $result = $this->getRedis()->append($key, $value); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "append", "(", "$", "key", ",", "$", "value", ")", "{", "try", "{", "$", "result", "=", "$", "this", "->", "getRedis", "(", ")", "->", "append", "(", "$", "key", ",", "$", "value", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "throw", "new", "ImpossibleValueException", "(", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Append string value @param string $key key @param string $value appended value @return int length of a key after append @throws ConnectException
[ "Append", "string", "value" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L152-L162
433
alxmsl/Connection
source/Redis/Connection.php
Connection.mget
public function mget(array $keys) { try { $result = $this->getRedis()->mGet($keys); if ($result !== false) { return array_combine($keys, $result); } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function mget(array $keys) { try { $result = $this->getRedis()->mGet($keys); if ($result !== false) { return array_combine($keys, $result); } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "mget", "(", "array", "$", "keys", ")", "{", "try", "{", "$", "result", "=", "$", "this", "->", "getRedis", "(", ")", "->", "mGet", "(", "$", "keys", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "array_combine", "(", "$", "keys", ",", "$", "result", ")", ";", "}", "throw", "new", "ImpossibleValueException", "(", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Get multiple keys values @param array $keys keys @return array values @throws ConnectException exception on connection to redis instance
[ "Get", "multiple", "keys", "values" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L189-L199
434
alxmsl/Connection
source/Redis/Connection.php
Connection.set
public function set($key, $value, $timeout = 0) { try { $result = ($timeout == 0) ? $this->getRedis()->set($key, $value) : $this->getRedis()->psetex($key, $timeout, $value); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function set($key, $value, $timeout = 0) { try { $result = ($timeout == 0) ? $this->getRedis()->set($key, $value) : $this->getRedis()->psetex($key, $timeout, $value); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "timeout", "=", "0", ")", "{", "try", "{", "$", "result", "=", "(", "$", "timeout", "==", "0", ")", "?", "$", "this", "->", "getRedis", "(", ")", "->", "set", "(", "$", "key", ",", "$", "value", ")", ":", "$", "this", "->", "getRedis", "(", ")", "->", "psetex", "(", "$", "key", ",", "$", "timeout", ",", "$", "value", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "throw", "new", "ImpossibleValueException", "(", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Set key value @param string $key key @param mixed $value value @param int $timeout ttl timeout in milliseconds @return bool operation result @throws ConnectException exception on connection to redis instance
[ "Set", "key", "value" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L209-L221
435
alxmsl/Connection
source/Redis/Connection.php
Connection.setnx
public function setnx($key, $value) { try { return $this->getRedis()->setnx($key, $value); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function setnx($key, $value) { try { return $this->getRedis()->setnx($key, $value); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "setnx", "(", "$", "key", ",", "$", "value", ")", "{", "try", "{", "return", "$", "this", "->", "getRedis", "(", ")", "->", "setnx", "(", "$", "key", ",", "$", "value", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Set key value if not exists @param string $key key @param mixed $value value @return bool returns true, if operation complete succesfull, else false @throws ConnectException exception on connection to redis instance
[ "Set", "key", "value", "if", "not", "exists" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L244-L250
436
alxmsl/Connection
source/Redis/Connection.php
Connection.delete
public function delete($keys) { try { $result = $this->getRedis()->delete($keys); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function delete($keys) { try { $result = $this->getRedis()->delete($keys); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "delete", "(", "$", "keys", ")", "{", "try", "{", "$", "result", "=", "$", "this", "->", "getRedis", "(", ")", "->", "delete", "(", "$", "keys", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "throw", "new", "ImpossibleValueException", "(", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Delete key or keys @param string|array $keys key or keys array @return int count of deleted keys @throws ConnectException exception on connection to redis instance
[ "Delete", "key", "or", "keys" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L287-L297
437
alxmsl/Connection
source/Redis/Connection.php
Connection.renamenx
public function renamenx($source, $destination) { try { return $this->getRedis()->renamenx($source, $destination); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function renamenx($source, $destination) { try { return $this->getRedis()->renamenx($source, $destination); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "renamenx", "(", "$", "source", ",", "$", "destination", ")", "{", "try", "{", "return", "$", "this", "->", "getRedis", "(", ")", "->", "renamenx", "(", "$", "source", ",", "$", "destination", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Rename key if needed key name was not @param string $source current key name @param string $destination needed key name @return bool operation result. If false, source key not found or needed key name found @throws ConnectException exception on connection to redis instance
[ "Rename", "key", "if", "needed", "key", "name", "was", "not" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L335-L341
438
alxmsl/Connection
source/Redis/Connection.php
Connection.strlen
public function strlen($key) { try { $result = $this->getRedis()->strlen($key); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function strlen($key) { try { $result = $this->getRedis()->strlen($key); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "strlen", "(", "$", "key", ")", "{", "try", "{", "$", "result", "=", "$", "this", "->", "getRedis", "(", ")", "->", "strlen", "(", "$", "key", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "throw", "new", "ImpossibleValueException", "(", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Get string length of a key @param string $key key @return int key value length @throws ConnectException exception on connection to redis instance
[ "Get", "string", "length", "of", "a", "key" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L349-L359
439
alxmsl/Connection
source/Redis/Connection.php
Connection.expire
public function expire($key, $timeout) { try { return $this->getRedis()->pexpire($key, $timeout); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function expire($key, $timeout) { try { return $this->getRedis()->pexpire($key, $timeout); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "expire", "(", "$", "key", ",", "$", "timeout", ")", "{", "try", "{", "return", "$", "this", "->", "getRedis", "(", ")", "->", "pexpire", "(", "$", "key", ",", "$", "timeout", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Set ttl for a key @param string $key key @param int $timeout ttl in milliseconds @return bool operation result. If false ttl cound not be set, or key not found @throws ConnectException exception on connection to redis instance
[ "Set", "ttl", "for", "a", "key" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L368-L374
440
alxmsl/Connection
source/Redis/Connection.php
Connection.expireat
public function expireat($key, $timestamp) { try { return $this->getRedis()->expireat($key, $timestamp); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function expireat($key, $timestamp) { try { return $this->getRedis()->expireat($key, $timestamp); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "expireat", "(", "$", "key", ",", "$", "timestamp", ")", "{", "try", "{", "return", "$", "this", "->", "getRedis", "(", ")", "->", "expireat", "(", "$", "key", ",", "$", "timestamp", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Set time of life for the key @param string $key key @param int $timestamp unix timestamp of time of death @return bool operation result. If false timestamp cound not be set, or key not found @throws ConnectException exception on connection to redis instance
[ "Set", "time", "of", "life", "for", "the", "key" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L383-L389
441
alxmsl/Connection
source/Redis/Connection.php
Connection.ttl
public function ttl($key) { try { $result = $this->getRedis()->pttl($key); return ($result != -1) ? $result : false; } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function ttl($key) { try { $result = $this->getRedis()->pttl($key); return ($result != -1) ? $result : false; } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "ttl", "(", "$", "key", ")", "{", "try", "{", "$", "result", "=", "$", "this", "->", "getRedis", "(", ")", "->", "pttl", "(", "$", "key", ")", ";", "return", "(", "$", "result", "!=", "-", "1", ")", "?", "$", "result", ":", "false", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Get ttl of the key @param string $key key @return int|bool ttl in milliseconds or false, if ttl is not set or key not found @throws ConnectException exception on connection to redis instance
[ "Get", "ttl", "of", "the", "key" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L397-L404
442
alxmsl/Connection
source/Redis/Connection.php
Connection.getbit
public function getbit($key, $offset) { $offset = (int) $offset; try { $result = $this->getRedis()->getBit($key, $offset); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function getbit($key, $offset) { $offset = (int) $offset; try { $result = $this->getRedis()->getBit($key, $offset); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "getbit", "(", "$", "key", ",", "$", "offset", ")", "{", "$", "offset", "=", "(", "int", ")", "$", "offset", ";", "try", "{", "$", "result", "=", "$", "this", "->", "getRedis", "(", ")", "->", "getBit", "(", "$", "key", ",", "$", "offset", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "throw", "new", "ImpossibleValueException", "(", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Get key bit @param string $key key @param int $offset bit offset @return int bit value at the offset @throws ConnectException exception on connection to redis instance
[ "Get", "key", "bit" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L427-L438
443
alxmsl/Connection
source/Redis/Connection.php
Connection.setbit
public function setbit($key, $offset, $value) { $offset = (int) $offset; $value = (int) (bool) $value; try { $result = $this->getRedis()->setBit($key, $offset, $value); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function setbit($key, $offset, $value) { $offset = (int) $offset; $value = (int) (bool) $value; try { $result = $this->getRedis()->setBit($key, $offset, $value); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "setbit", "(", "$", "key", ",", "$", "offset", ",", "$", "value", ")", "{", "$", "offset", "=", "(", "int", ")", "$", "offset", ";", "$", "value", "=", "(", "int", ")", "(", "bool", ")", "$", "value", ";", "try", "{", "$", "result", "=", "$", "this", "->", "getRedis", "(", ")", "->", "setBit", "(", "$", "key", ",", "$", "offset", ",", "$", "value", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "throw", "new", "ImpossibleValueException", "(", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Set key bit @param string $key key @param int $offset bit offset @param int $value bit value. May be 0 or 1 @return int bit value before operation complete @throws ConnectException exception on connection to redis instance
[ "Set", "key", "bit" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L448-L460
444
alxmsl/Connection
source/Redis/Connection.php
Connection.evaluate
public function evaluate($code, array $arguments = array()) { try { if (empty($arguments)) { $result = $this->getRedis()->eval($code); } else { $result = $this->getRedis()->eval($code, $arguments, count($arguments)); } $lastError = $this->getRedis()->getLastError(); $this->getRedis()->clearLastError(); if (is_null($lastError)) { return $result; } throw new ScriptExecutionException($lastError); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function evaluate($code, array $arguments = array()) { try { if (empty($arguments)) { $result = $this->getRedis()->eval($code); } else { $result = $this->getRedis()->eval($code, $arguments, count($arguments)); } $lastError = $this->getRedis()->getLastError(); $this->getRedis()->clearLastError(); if (is_null($lastError)) { return $result; } throw new ScriptExecutionException($lastError); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "evaluate", "(", "$", "code", ",", "array", "$", "arguments", "=", "array", "(", ")", ")", "{", "try", "{", "if", "(", "empty", "(", "$", "arguments", ")", ")", "{", "$", "result", "=", "$", "this", "->", "getRedis", "(", ")", "->", "eval", "(", "$", "code", ")", ";", "}", "else", "{", "$", "result", "=", "$", "this", "->", "getRedis", "(", ")", "->", "eval", "(", "$", "code", ",", "$", "arguments", ",", "count", "(", "$", "arguments", ")", ")", ";", "}", "$", "lastError", "=", "$", "this", "->", "getRedis", "(", ")", "->", "getLastError", "(", ")", ";", "$", "this", "->", "getRedis", "(", ")", "->", "clearLastError", "(", ")", ";", "if", "(", "is_null", "(", "$", "lastError", ")", ")", "{", "return", "$", "result", ";", "}", "throw", "new", "ScriptExecutionException", "(", "$", "lastError", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Evaluate Lua code @param string $code string of Lua code @param array $arguments array of Lua script arguments @return mixed code execution result @throws ConnectException exception on connection to redis instance @throws ScriptExecutionException when script execution faled
[ "Evaluate", "Lua", "code" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L470-L487
445
alxmsl/Connection
source/Redis/Connection.php
Connection.evalSha
public function evalSha($sha, array $arguments = array()) { try { if (empty($arguments)) { $result = $this->getRedis()->evalSha($sha); } else { $result = $this->getRedis()->evalSha($sha, $arguments, count($arguments)); } $lastError = $this->getRedis()->getLastError(); $this->getRedis()->clearLastError(); if (is_null($lastError)) { return $result; } throw new ScriptExecutionException($lastError); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function evalSha($sha, array $arguments = array()) { try { if (empty($arguments)) { $result = $this->getRedis()->evalSha($sha); } else { $result = $this->getRedis()->evalSha($sha, $arguments, count($arguments)); } $lastError = $this->getRedis()->getLastError(); $this->getRedis()->clearLastError(); if (is_null($lastError)) { return $result; } throw new ScriptExecutionException($lastError); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "evalSha", "(", "$", "sha", ",", "array", "$", "arguments", "=", "array", "(", ")", ")", "{", "try", "{", "if", "(", "empty", "(", "$", "arguments", ")", ")", "{", "$", "result", "=", "$", "this", "->", "getRedis", "(", ")", "->", "evalSha", "(", "$", "sha", ")", ";", "}", "else", "{", "$", "result", "=", "$", "this", "->", "getRedis", "(", ")", "->", "evalSha", "(", "$", "sha", ",", "$", "arguments", ",", "count", "(", "$", "arguments", ")", ")", ";", "}", "$", "lastError", "=", "$", "this", "->", "getRedis", "(", ")", "->", "getLastError", "(", ")", ";", "$", "this", "->", "getRedis", "(", ")", "->", "clearLastError", "(", ")", ";", "if", "(", "is_null", "(", "$", "lastError", ")", ")", "{", "return", "$", "result", ";", "}", "throw", "new", "ScriptExecutionException", "(", "$", "lastError", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Evaluate Lua code by hash @param string $sha SHA1 string of Lua code @param array $arguments array of Lua script arguments @return mixed code execution result @throws ConnectException exception on connection to redis instance @throws ScriptExecutionException when script execution faled
[ "Evaluate", "Lua", "code", "by", "hash" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L497-L514
446
alxmsl/Connection
source/Redis/Connection.php
Connection.sadd
public function sadd($key, $member) { try { $result = $this->getRedis()->sAdd($key, $member); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function sadd($key, $member) { try { $result = $this->getRedis()->sAdd($key, $member); if ($result !== false) { return $result; } throw new ImpossibleValueException(); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "sadd", "(", "$", "key", ",", "$", "member", ")", "{", "try", "{", "$", "result", "=", "$", "this", "->", "getRedis", "(", ")", "->", "sAdd", "(", "$", "key", ",", "$", "member", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "throw", "new", "ImpossibleValueException", "(", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Add member to the set @param string $key key @param mixed $member set member @return int count of added members @throws ConnectException exception on connection to redis instance
[ "Add", "member", "to", "the", "set" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L523-L533
447
alxmsl/Connection
source/Redis/Connection.php
Connection.sismembers
public function sismembers($key, $member) { try { return $this->getRedis()->sIsMember($key, $member); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function sismembers($key, $member) { try { return $this->getRedis()->sIsMember($key, $member); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "sismembers", "(", "$", "key", ",", "$", "member", ")", "{", "try", "{", "return", "$", "this", "->", "getRedis", "(", ")", "->", "sIsMember", "(", "$", "key", ",", "$", "member", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Check that member is a member of the set @param string $key key @param mixed $member member @return bool check result @throws ConnectException exception on connection to redis instance
[ "Check", "that", "member", "is", "a", "member", "of", "the", "set" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L584-L590
448
alxmsl/Connection
source/Redis/Connection.php
Connection.srem
public function srem($key, $member) { try { return $this->getRedis()->sRem($key, $member); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function srem($key, $member) { try { return $this->getRedis()->sRem($key, $member); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "srem", "(", "$", "key", ",", "$", "member", ")", "{", "try", "{", "return", "$", "this", "->", "getRedis", "(", ")", "->", "sRem", "(", "$", "key", ",", "$", "member", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Remove member from the set @param string $key key @param mixed $member set member @return int count of removed elements @throws ConnectException exception on connection to redis instance
[ "Remove", "member", "from", "the", "set" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L613-L619
449
alxmsl/Connection
source/Redis/Connection.php
Connection.sdiffstore
public function sdiffstore($destination, array $sources) { try { return call_user_func_array(array( $this->getRedis(), 'sDiffStore', ), array_merge(array($destination), $sources)); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function sdiffstore($destination, array $sources) { try { return call_user_func_array(array( $this->getRedis(), 'sDiffStore', ), array_merge(array($destination), $sources)); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "sdiffstore", "(", "$", "destination", ",", "array", "$", "sources", ")", "{", "try", "{", "return", "call_user_func_array", "(", "array", "(", "$", "this", "->", "getRedis", "(", ")", ",", "'sDiffStore'", ",", ")", ",", "array_merge", "(", "array", "(", "$", "destination", ")", ",", "$", "sources", ")", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Create difference set @param string $destination key for result set @param array $sources source keys @return int size of result set @throws ConnectException exception on connection to redis instance
[ "Create", "difference", "set" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L628-L637
450
alxmsl/Connection
source/Redis/Connection.php
Connection.rpush
public function rpush($key, $member) { try { return $this->getRedis()->rPush($key, $member); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function rpush($key, $member) { try { return $this->getRedis()->rPush($key, $member); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "rpush", "(", "$", "key", ",", "$", "member", ")", "{", "try", "{", "return", "$", "this", "->", "getRedis", "(", ")", "->", "rPush", "(", "$", "key", ",", "$", "member", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Append value to a list @param string $key key @param mixed $member list member @return int list length
[ "Append", "value", "to", "a", "list" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L645-L651
451
alxmsl/Connection
source/Redis/Connection.php
Connection.llen
public function llen($key) { try { $length = $this->getRedis()->lLen($key); if ($length === false) { throw new ImpossibleValueException(); } return $length; } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function llen($key) { try { $length = $this->getRedis()->lLen($key); if ($length === false) { throw new ImpossibleValueException(); } return $length; } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "llen", "(", "$", "key", ")", "{", "try", "{", "$", "length", "=", "$", "this", "->", "getRedis", "(", ")", "->", "lLen", "(", "$", "key", ")", ";", "if", "(", "$", "length", "===", "false", ")", "{", "throw", "new", "ImpossibleValueException", "(", ")", ";", "}", "return", "$", "length", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Returns list length @param string $key list key @throws ConnectException exception on connection to redis instance @throws ImpossibleValueException when found key is not a list
[ "Returns", "list", "length" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L699-L709
452
alxmsl/Connection
source/Redis/Connection.php
Connection.publish
public function publish($channel, $message) { try { return $this->getRedis()->publish($channel, $message); } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function publish($channel, $message) { try { return $this->getRedis()->publish($channel, $message); } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "publish", "(", "$", "channel", ",", "$", "message", ")", "{", "try", "{", "return", "$", "this", "->", "getRedis", "(", ")", "->", "publish", "(", "$", "channel", ",", "$", "message", ")", ";", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Publish message to channel @param string $channel channel name @param string $message message @return int the number of clients that received the message
[ "Publish", "message", "to", "channel" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L717-L723
453
alxmsl/Connection
source/Redis/Connection.php
Connection.transaction
public function transaction(Closure $Commands, $mode = Redis::MULTI) { try { $Instance = $this->multi($mode); $result = $Commands($Instance); if ($result == true) { return $Instance->exec(); } else { $Instance->discard(); return false; } } catch (RedisException $ex) { throw new ConnectException(); } }
php
public function transaction(Closure $Commands, $mode = Redis::MULTI) { try { $Instance = $this->multi($mode); $result = $Commands($Instance); if ($result == true) { return $Instance->exec(); } else { $Instance->discard(); return false; } } catch (RedisException $ex) { throw new ConnectException(); } }
[ "public", "function", "transaction", "(", "Closure", "$", "Commands", ",", "$", "mode", "=", "Redis", "::", "MULTI", ")", "{", "try", "{", "$", "Instance", "=", "$", "this", "->", "multi", "(", "$", "mode", ")", ";", "$", "result", "=", "$", "Commands", "(", "$", "Instance", ")", ";", "if", "(", "$", "result", "==", "true", ")", "{", "return", "$", "Instance", "->", "exec", "(", ")", ";", "}", "else", "{", "$", "Instance", "->", "discard", "(", ")", ";", "return", "false", ";", "}", "}", "catch", "(", "RedisException", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", ")", ";", "}", "}" ]
Execute transaction method @param callable $Commands function, that have Redis instance as a first argument. Must returns boolean value for execute or discard all commands @param string $mode transaction mode @return array|false transaction execution result or false on failure
[ "Execute", "transaction", "method" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/Connection.php#L754-L767
454
SergioMadness/framework
framework/web/Response.php
Response.prepareBody
protected function prepareBody() { $body = $this->body; $result = $body; if ($this->isJson() && (is_array($body) || is_object($body))) { $result = json_encode(\pwf\helpers\ArrayHelper::toArray($body)); } return $result; }
php
protected function prepareBody() { $body = $this->body; $result = $body; if ($this->isJson() && (is_array($body) || is_object($body))) { $result = json_encode(\pwf\helpers\ArrayHelper::toArray($body)); } return $result; }
[ "protected", "function", "prepareBody", "(", ")", "{", "$", "body", "=", "$", "this", "->", "body", ";", "$", "result", "=", "$", "body", ";", "if", "(", "$", "this", "->", "isJson", "(", ")", "&&", "(", "is_array", "(", "$", "body", ")", "||", "is_object", "(", "$", "body", ")", ")", ")", "{", "$", "result", "=", "json_encode", "(", "\\", "pwf", "\\", "helpers", "\\", "ArrayHelper", "::", "toArray", "(", "$", "body", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Prepare response body for sending @return string
[ "Prepare", "response", "body", "for", "sending" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/web/Response.php#L214-L225
455
novuso/common
src/Domain/Type/MbStringObject.php
MbStringObject.padString
private static function padString(string $string, int $left, int $right, string $char): string { $leftPadding = str_repeat($char, $left); $rightPadding = str_repeat($char, $right); return $leftPadding.$string.$rightPadding; }
php
private static function padString(string $string, int $left, int $right, string $char): string { $leftPadding = str_repeat($char, $left); $rightPadding = str_repeat($char, $right); return $leftPadding.$string.$rightPadding; }
[ "private", "static", "function", "padString", "(", "string", "$", "string", ",", "int", "$", "left", ",", "int", "$", "right", ",", "string", "$", "char", ")", ":", "string", "{", "$", "leftPadding", "=", "str_repeat", "(", "$", "char", ",", "$", "left", ")", ";", "$", "rightPadding", "=", "str_repeat", "(", "$", "char", ",", "$", "right", ")", ";", "return", "$", "leftPadding", ".", "$", "string", ".", "$", "rightPadding", ";", "}" ]
Applies padding to a string @param string $string The original string @param int $left The left padding size @param int $right The right padding size @param string $char The padding character @return string
[ "Applies", "padding", "to", "a", "string" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Type/MbStringObject.php#L887-L893
456
romeOz/rock-url
src/Url.php
Url.set
public static function set($url = null, array $config = []) { $config['class'] = static::className(); return Instance::ensure($config, static::className(), [$url]); }
php
public static function set($url = null, array $config = []) { $config['class'] = static::className(); return Instance::ensure($config, static::className(), [$url]); }
[ "public", "static", "function", "set", "(", "$", "url", "=", "null", ",", "array", "$", "config", "=", "[", "]", ")", "{", "$", "config", "[", "'class'", "]", "=", "static", "::", "className", "(", ")", ";", "return", "Instance", "::", "ensure", "(", "$", "config", ",", "static", "::", "className", "(", ")", ",", "[", "$", "url", "]", ")", ";", "}" ]
Modify URL. @param string|null $url URL for modify (default: NULL) @param array $config the configuration. It can be either a string representing the class name or an array representing the object configuration. @return $this
[ "Modify", "URL", "." ]
e1876589bb92ccb5d75fd1c0d63ce87d5886daf3
https://github.com/romeOz/rock-url/blob/e1876589bb92ccb5d75fd1c0d63ce87d5886daf3/src/Url.php#L115-L119
457
romeOz/rock-url
src/Url.php
Url.replacePath
public function replacePath($value, $replace) { $this->data['path'] = str_replace($value, $replace, $this->data['path']); return $this; }
php
public function replacePath($value, $replace) { $this->data['path'] = str_replace($value, $replace, $this->data['path']); return $this; }
[ "public", "function", "replacePath", "(", "$", "value", ",", "$", "replace", ")", "{", "$", "this", "->", "data", "[", "'path'", "]", "=", "str_replace", "(", "$", "value", ",", "$", "replace", ",", "$", "this", "->", "data", "[", "'path'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Replacing path. @param string $value @param string $replace @return $this
[ "Replacing", "path", "." ]
e1876589bb92ccb5d75fd1c0d63ce87d5886daf3
https://github.com/romeOz/rock-url/blob/e1876589bb92ccb5d75fd1c0d63ce87d5886daf3/src/Url.php#L304-L308
458
romeOz/rock-url
src/Url.php
Url.setQuery
public function setQuery($query) { if (!empty($query)) { $this->data['query'] = $this->_queryToArray($query); } return $this; }
php
public function setQuery($query) { if (!empty($query)) { $this->data['query'] = $this->_queryToArray($query); } return $this; }
[ "public", "function", "setQuery", "(", "$", "query", ")", "{", "if", "(", "!", "empty", "(", "$", "query", ")", ")", "{", "$", "this", "->", "data", "[", "'query'", "]", "=", "$", "this", "->", "_queryToArray", "(", "$", "query", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets a query. @param string $query query. @return $this
[ "Sets", "a", "query", "." ]
e1876589bb92ccb5d75fd1c0d63ce87d5886daf3
https://github.com/romeOz/rock-url/blob/e1876589bb92ccb5d75fd1c0d63ce87d5886daf3/src/Url.php#L315-L322
459
romeOz/rock-url
src/Url.php
Url.addQueryParams
public function addQueryParams(array $queryParams) { $this->data['query'] = array_merge(Helper::getValue($this->data['query'], []), $queryParams); $this->data['query'] = array_filter($this->data['query']); return $this; }
php
public function addQueryParams(array $queryParams) { $this->data['query'] = array_merge(Helper::getValue($this->data['query'], []), $queryParams); $this->data['query'] = array_filter($this->data['query']); return $this; }
[ "public", "function", "addQueryParams", "(", "array", "$", "queryParams", ")", "{", "$", "this", "->", "data", "[", "'query'", "]", "=", "array_merge", "(", "Helper", "::", "getValue", "(", "$", "this", "->", "data", "[", "'query'", "]", ",", "[", "]", ")", ",", "$", "queryParams", ")", ";", "$", "this", "->", "data", "[", "'query'", "]", "=", "array_filter", "(", "$", "this", "->", "data", "[", "'query'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Adds a query params. @param array $queryParams list arguments. @return $this
[ "Adds", "a", "query", "params", "." ]
e1876589bb92ccb5d75fd1c0d63ce87d5886daf3
https://github.com/romeOz/rock-url/blob/e1876589bb92ccb5d75fd1c0d63ce87d5886daf3/src/Url.php#L354-L359
460
romeOz/rock-url
src/Url.php
Url.removeQueryParams
public function removeQueryParams(array $queryParams) { if (empty($this->data['query'])) { return $this; } $this->data['query'] = array_diff_key( $this->data['query'], array_flip($queryParams) ); return $this; }
php
public function removeQueryParams(array $queryParams) { if (empty($this->data['query'])) { return $this; } $this->data['query'] = array_diff_key( $this->data['query'], array_flip($queryParams) ); return $this; }
[ "public", "function", "removeQueryParams", "(", "array", "$", "queryParams", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "data", "[", "'query'", "]", ")", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "data", "[", "'query'", "]", "=", "array_diff_key", "(", "$", "this", "->", "data", "[", "'query'", "]", ",", "array_flip", "(", "$", "queryParams", ")", ")", ";", "return", "$", "this", ";", "}" ]
Removes a query params. @param array $queryParams arguments @return $this
[ "Removes", "a", "query", "params", "." ]
e1876589bb92ccb5d75fd1c0d63ce87d5886daf3
https://github.com/romeOz/rock-url/blob/e1876589bb92ccb5d75fd1c0d63ce87d5886daf3/src/Url.php#L379-L391
461
romeOz/rock-url
src/Url.php
Url.replace
public function replace(array $placeholders = []) { if (empty($placeholders)) { return $this; } $callback = function ($value) use ($placeholders) { return StringHelper::replace($value, $placeholders, false); }; $this->data = ArrayHelper::map($this->data, $callback, true); return $this; }
php
public function replace(array $placeholders = []) { if (empty($placeholders)) { return $this; } $callback = function ($value) use ($placeholders) { return StringHelper::replace($value, $placeholders, false); }; $this->data = ArrayHelper::map($this->data, $callback, true); return $this; }
[ "public", "function", "replace", "(", "array", "$", "placeholders", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "placeholders", ")", ")", "{", "return", "$", "this", ";", "}", "$", "callback", "=", "function", "(", "$", "value", ")", "use", "(", "$", "placeholders", ")", "{", "return", "StringHelper", "::", "replace", "(", "$", "value", ",", "$", "placeholders", ",", "false", ")", ";", "}", ";", "$", "this", "->", "data", "=", "ArrayHelper", "::", "map", "(", "$", "this", "->", "data", ",", "$", "callback", ",", "true", ")", ";", "return", "$", "this", ";", "}" ]
Replacing placeholders to URL-data. @param array $placeholders @return static
[ "Replacing", "placeholders", "to", "URL", "-", "data", "." ]
e1876589bb92ccb5d75fd1c0d63ce87d5886daf3
https://github.com/romeOz/rock-url/blob/e1876589bb92ccb5d75fd1c0d63ce87d5886daf3/src/Url.php#L431-L441
462
romeOz/rock-url
src/Url.php
Url.get
public function get($scheme = self::REL) { $data = $this->data; if ($scheme == self::REL) { unset($data['scheme'], $data['host'], $data['user'], $data['pass'], $data['port']); return $this->build($data); } if (!isset($data['host'])) { $data['host'] = $this->request->getHost(); } if (!isset($data['scheme'])) { $scheme = self::SHORT_ABS; } if ($scheme == self::SHORT_ABS) { unset($data['scheme']); $url = $this->build($data, '//'); } else { $url = $this->build($data); } return $this->asProtect($url, $data['host']); }
php
public function get($scheme = self::REL) { $data = $this->data; if ($scheme == self::REL) { unset($data['scheme'], $data['host'], $data['user'], $data['pass'], $data['port']); return $this->build($data); } if (!isset($data['host'])) { $data['host'] = $this->request->getHost(); } if (!isset($data['scheme'])) { $scheme = self::SHORT_ABS; } if ($scheme == self::SHORT_ABS) { unset($data['scheme']); $url = $this->build($data, '//'); } else { $url = $this->build($data); } return $this->asProtect($url, $data['host']); }
[ "public", "function", "get", "(", "$", "scheme", "=", "self", "::", "REL", ")", "{", "$", "data", "=", "$", "this", "->", "data", ";", "if", "(", "$", "scheme", "==", "self", "::", "REL", ")", "{", "unset", "(", "$", "data", "[", "'scheme'", "]", ",", "$", "data", "[", "'host'", "]", ",", "$", "data", "[", "'user'", "]", ",", "$", "data", "[", "'pass'", "]", ",", "$", "data", "[", "'port'", "]", ")", ";", "return", "$", "this", "->", "build", "(", "$", "data", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "data", "[", "'host'", "]", ")", ")", "{", "$", "data", "[", "'host'", "]", "=", "$", "this", "->", "request", "->", "getHost", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "data", "[", "'scheme'", "]", ")", ")", "{", "$", "scheme", "=", "self", "::", "SHORT_ABS", ";", "}", "if", "(", "$", "scheme", "==", "self", "::", "SHORT_ABS", ")", "{", "unset", "(", "$", "data", "[", "'scheme'", "]", ")", ";", "$", "url", "=", "$", "this", "->", "build", "(", "$", "data", ",", "'//'", ")", ";", "}", "else", "{", "$", "url", "=", "$", "this", "->", "build", "(", "$", "data", ")", ";", "}", "return", "$", "this", "->", "asProtect", "(", "$", "url", ",", "$", "data", "[", "'host'", "]", ")", ";", "}" ]
Returns formatted URL. @param string $scheme @return null|string
[ "Returns", "formatted", "URL", "." ]
e1876589bb92ccb5d75fd1c0d63ce87d5886daf3
https://github.com/romeOz/rock-url/blob/e1876589bb92ccb5d75fd1c0d63ce87d5886daf3/src/Url.php#L459-L481
463
romeOz/rock-url
src/Url.php
Url.offsetSet
public function offsetSet($key, $value) { if ($key === 'query' && isset($value)) { $value = $this->_queryToArray($value); } $this->data[$key] = $value; }
php
public function offsetSet($key, $value) { if ($key === 'query' && isset($value)) { $value = $this->_queryToArray($value); } $this->data[$key] = $value; }
[ "public", "function", "offsetSet", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "key", "===", "'query'", "&&", "isset", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "_queryToArray", "(", "$", "value", ")", ";", "}", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Sets a URL-data by key. @param string $key key of data. @param $value
[ "Sets", "a", "URL", "-", "data", "by", "key", "." ]
e1876589bb92ccb5d75fd1c0d63ce87d5886daf3
https://github.com/romeOz/rock-url/blob/e1876589bb92ccb5d75fd1c0d63ce87d5886daf3/src/Url.php#L539-L545
464
tzurbaev/api-client
src/Helpers/FakeResponse.php
FakeResponse.toResponse
public function toResponse(): Response { return new Response( $this->status, $this->headers, $this->body, $this->httpVersion, $this->reason ); }
php
public function toResponse(): Response { return new Response( $this->status, $this->headers, $this->body, $this->httpVersion, $this->reason ); }
[ "public", "function", "toResponse", "(", ")", ":", "Response", "{", "return", "new", "Response", "(", "$", "this", "->", "status", ",", "$", "this", "->", "headers", ",", "$", "this", "->", "body", ",", "$", "this", "->", "httpVersion", ",", "$", "this", "->", "reason", ")", ";", "}" ]
Generates HTTP Response. @return Response
[ "Generates", "HTTP", "Response", "." ]
78cec644c2be7d732f1d826900e22f427de44f3c
https://github.com/tzurbaev/api-client/blob/78cec644c2be7d732f1d826900e22f427de44f3c/src/Helpers/FakeResponse.php#L141-L150
465
Laralum/Settings
src/Settings.php
Settings.view
public static function view($package) { $settings = static::get($package); if ($settings and array_key_exists('view', $settings)) { return view($settings['view']); } return ''; }
php
public static function view($package) { $settings = static::get($package); if ($settings and array_key_exists('view', $settings)) { return view($settings['view']); } return ''; }
[ "public", "static", "function", "view", "(", "$", "package", ")", "{", "$", "settings", "=", "static", "::", "get", "(", "$", "package", ")", ";", "if", "(", "$", "settings", "and", "array_key_exists", "(", "'view'", ",", "$", "settings", ")", ")", "{", "return", "view", "(", "$", "settings", "[", "'view'", "]", ")", ";", "}", "return", "''", ";", "}" ]
Returns the settings view of the package. @param string $package
[ "Returns", "the", "settings", "view", "of", "the", "package", "." ]
3d72a6a9343ce27c2401e3c42bb9f585bf49705a
https://github.com/Laralum/Settings/blob/3d72a6a9343ce27c2401e3c42bb9f585bf49705a/src/Settings.php#L49-L58
466
wasabi-cms/core
src/View/Helper/FormHelper.php
FormHelper._processTemplateVars
protected function _processTemplateVars(array $options) { $templateVars = isset($options['options']['templateVars']) ? $options['options']['templateVars'] : []; if (empty($templateVars)) { return $templateVars; } if (isset($templateVars['formRowLabel']) && $options['options']['id'] !== false) { $templateVars['formRowFor'] = ' for="' . $options['options']['id'] . '"'; } $wrapInSmall = [ 'formRowLabelInfo', 'formRowInfo', 'info' ]; foreach ($wrapInSmall as $attr) { if (isset($templateVars[$attr])) { $templateVars[$attr] = '<small>' . $templateVars[$attr] . '</small>'; } } return $templateVars; }
php
protected function _processTemplateVars(array $options) { $templateVars = isset($options['options']['templateVars']) ? $options['options']['templateVars'] : []; if (empty($templateVars)) { return $templateVars; } if (isset($templateVars['formRowLabel']) && $options['options']['id'] !== false) { $templateVars['formRowFor'] = ' for="' . $options['options']['id'] . '"'; } $wrapInSmall = [ 'formRowLabelInfo', 'formRowInfo', 'info' ]; foreach ($wrapInSmall as $attr) { if (isset($templateVars[$attr])) { $templateVars[$attr] = '<small>' . $templateVars[$attr] . '</small>'; } } return $templateVars; }
[ "protected", "function", "_processTemplateVars", "(", "array", "$", "options", ")", "{", "$", "templateVars", "=", "isset", "(", "$", "options", "[", "'options'", "]", "[", "'templateVars'", "]", ")", "?", "$", "options", "[", "'options'", "]", "[", "'templateVars'", "]", ":", "[", "]", ";", "if", "(", "empty", "(", "$", "templateVars", ")", ")", "{", "return", "$", "templateVars", ";", "}", "if", "(", "isset", "(", "$", "templateVars", "[", "'formRowLabel'", "]", ")", "&&", "$", "options", "[", "'options'", "]", "[", "'id'", "]", "!==", "false", ")", "{", "$", "templateVars", "[", "'formRowFor'", "]", "=", "' for=\"'", ".", "$", "options", "[", "'options'", "]", "[", "'id'", "]", ".", "'\"'", ";", "}", "$", "wrapInSmall", "=", "[", "'formRowLabelInfo'", ",", "'formRowInfo'", ",", "'info'", "]", ";", "foreach", "(", "$", "wrapInSmall", "as", "$", "attr", ")", "{", "if", "(", "isset", "(", "$", "templateVars", "[", "$", "attr", "]", ")", ")", "{", "$", "templateVars", "[", "$", "attr", "]", "=", "'<small>'", ".", "$", "templateVars", "[", "$", "attr", "]", ".", "'</small>'", ";", "}", "}", "return", "$", "templateVars", ";", "}" ]
Process templateVars to wrap info elements in a small tag and apply the "for" attribute to form row labels. @param array $options The input options @return array
[ "Process", "templateVars", "to", "wrap", "info", "elements", "in", "a", "small", "tag", "and", "apply", "the", "for", "attribute", "to", "form", "row", "labels", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/FormHelper.php#L49-L74
467
wasabi-cms/core
src/View/Helper/FormHelper.php
FormHelper.getLabel
public function getLabel($text, $info = null) { $options = [ 'text' => $text, 'templateVars' => [] ]; if ($info !== null) { $options['templateVars']['labelInfo'] = '<small>' . $info . '</small>'; } return $options; }
php
public function getLabel($text, $info = null) { $options = [ 'text' => $text, 'templateVars' => [] ]; if ($info !== null) { $options['templateVars']['labelInfo'] = '<small>' . $info . '</small>'; } return $options; }
[ "public", "function", "getLabel", "(", "$", "text", ",", "$", "info", "=", "null", ")", "{", "$", "options", "=", "[", "'text'", "=>", "$", "text", ",", "'templateVars'", "=>", "[", "]", "]", ";", "if", "(", "$", "info", "!==", "null", ")", "{", "$", "options", "[", "'templateVars'", "]", "[", "'labelInfo'", "]", "=", "'<small>'", ".", "$", "info", ".", "'</small>'", ";", "}", "return", "$", "options", ";", "}" ]
Get the options array for a label. This handles the optional placement of an info text below the label. @param string $text The label text. @param null|string $info The optional label info. @return array
[ "Get", "the", "options", "array", "for", "a", "label", ".", "This", "handles", "the", "optional", "placement", "of", "an", "info", "text", "below", "the", "label", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/FormHelper.php#L84-L96
468
wasabi-cms/core
src/View/Helper/FormHelper.php
FormHelper.timeZoneSelect
public function timeZoneSelect($field, array $options = []) { $regions = [ 'Europe' => DateTimeZone::EUROPE, 'America' => DateTimeZone::AMERICA, 'Africa' => DateTimeZone::AFRICA, 'Antarctica' => DateTimeZone::ANTARCTICA, 'Asia' => DateTimeZone::ASIA, 'Atlantic' => DateTimeZone::ATLANTIC, 'Indian' => DateTimeZone::INDIAN, 'Pacific' => DateTimeZone::PACIFIC ]; $timezones = []; foreach ($regions as $name => $mask) { $zones = DateTimeZone::listIdentifiers($mask); foreach ($zones as $timezone) { // Lets sample the time there right now $time = new DateTime(null, new DateTimeZone($timezone)); // Us dumb Americans can't handle millitary time // Remove region name and add a sample time $timezones[$name][] = [ 'value' => $timezone, 'text' => 'UTC ' . $time->format('P') . ' ' . substr($timezone, strlen($name) + 1) ]; } } $options['options'] = $timezones; return $this->input($field, $options); }
php
public function timeZoneSelect($field, array $options = []) { $regions = [ 'Europe' => DateTimeZone::EUROPE, 'America' => DateTimeZone::AMERICA, 'Africa' => DateTimeZone::AFRICA, 'Antarctica' => DateTimeZone::ANTARCTICA, 'Asia' => DateTimeZone::ASIA, 'Atlantic' => DateTimeZone::ATLANTIC, 'Indian' => DateTimeZone::INDIAN, 'Pacific' => DateTimeZone::PACIFIC ]; $timezones = []; foreach ($regions as $name => $mask) { $zones = DateTimeZone::listIdentifiers($mask); foreach ($zones as $timezone) { // Lets sample the time there right now $time = new DateTime(null, new DateTimeZone($timezone)); // Us dumb Americans can't handle millitary time // Remove region name and add a sample time $timezones[$name][] = [ 'value' => $timezone, 'text' => 'UTC ' . $time->format('P') . ' ' . substr($timezone, strlen($name) + 1) ]; } } $options['options'] = $timezones; return $this->input($field, $options); }
[ "public", "function", "timeZoneSelect", "(", "$", "field", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "regions", "=", "[", "'Europe'", "=>", "DateTimeZone", "::", "EUROPE", ",", "'America'", "=>", "DateTimeZone", "::", "AMERICA", ",", "'Africa'", "=>", "DateTimeZone", "::", "AFRICA", ",", "'Antarctica'", "=>", "DateTimeZone", "::", "ANTARCTICA", ",", "'Asia'", "=>", "DateTimeZone", "::", "ASIA", ",", "'Atlantic'", "=>", "DateTimeZone", "::", "ATLANTIC", ",", "'Indian'", "=>", "DateTimeZone", "::", "INDIAN", ",", "'Pacific'", "=>", "DateTimeZone", "::", "PACIFIC", "]", ";", "$", "timezones", "=", "[", "]", ";", "foreach", "(", "$", "regions", "as", "$", "name", "=>", "$", "mask", ")", "{", "$", "zones", "=", "DateTimeZone", "::", "listIdentifiers", "(", "$", "mask", ")", ";", "foreach", "(", "$", "zones", "as", "$", "timezone", ")", "{", "// Lets sample the time there right now", "$", "time", "=", "new", "DateTime", "(", "null", ",", "new", "DateTimeZone", "(", "$", "timezone", ")", ")", ";", "// Us dumb Americans can't handle millitary time", "// Remove region name and add a sample time", "$", "timezones", "[", "$", "name", "]", "[", "]", "=", "[", "'value'", "=>", "$", "timezone", ",", "'text'", "=>", "'UTC '", ".", "$", "time", "->", "format", "(", "'P'", ")", ".", "' '", ".", "substr", "(", "$", "timezone", ",", "strlen", "(", "$", "name", ")", "+", "1", ")", "]", ";", "}", "}", "$", "options", "[", "'options'", "]", "=", "$", "timezones", ";", "return", "$", "this", "->", "input", "(", "$", "field", ",", "$", "options", ")", ";", "}" ]
Render a grouped time zone select box. @param string $field The input field name. @param array $options Additional options for the generated select. @return string
[ "Render", "a", "grouped", "time", "zone", "select", "box", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/FormHelper.php#L105-L133
469
wasabi-cms/core
src/View/Helper/FormHelper.php
FormHelper.toggleSwitch
public function toggleSwitch($fieldName, array $options = []) { $options += ['hiddenField' => true, 'value' => 1, 'id' => true]; // Work around value=>val translations. $value = $options['value']; unset($options['value']); $options = $this->_initInputField($fieldName, $options); $options['value'] = $value; $output = ''; if ($options['hiddenField']) { $hiddenOptions = [ 'name' => $options['name'], 'value' => ($options['hiddenField'] !== true && $options['hiddenField'] !== '_split' ? $options['hiddenField'] : '0'), 'form' => isset($options['form']) ? $options['form'] : null, 'secure' => false ]; if (isset($options['disabled']) && $options['disabled']) { $hiddenOptions['disabled'] = 'disabled'; } $output = $this->hidden($fieldName, $hiddenOptions); } if ($options['hiddenField'] === '_split') { unset($options['hiddenField'], $options['type']); return ['hidden' => $output, 'input' => $this->widget('checkbox', $options)]; } unset($options['hiddenField'], $options['type']); return $output . $this->widget('toggleSwitch', $options); }
php
public function toggleSwitch($fieldName, array $options = []) { $options += ['hiddenField' => true, 'value' => 1, 'id' => true]; // Work around value=>val translations. $value = $options['value']; unset($options['value']); $options = $this->_initInputField($fieldName, $options); $options['value'] = $value; $output = ''; if ($options['hiddenField']) { $hiddenOptions = [ 'name' => $options['name'], 'value' => ($options['hiddenField'] !== true && $options['hiddenField'] !== '_split' ? $options['hiddenField'] : '0'), 'form' => isset($options['form']) ? $options['form'] : null, 'secure' => false ]; if (isset($options['disabled']) && $options['disabled']) { $hiddenOptions['disabled'] = 'disabled'; } $output = $this->hidden($fieldName, $hiddenOptions); } if ($options['hiddenField'] === '_split') { unset($options['hiddenField'], $options['type']); return ['hidden' => $output, 'input' => $this->widget('checkbox', $options)]; } unset($options['hiddenField'], $options['type']); return $output . $this->widget('toggleSwitch', $options); }
[ "public", "function", "toggleSwitch", "(", "$", "fieldName", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'hiddenField'", "=>", "true", ",", "'value'", "=>", "1", ",", "'id'", "=>", "true", "]", ";", "// Work around value=>val translations.", "$", "value", "=", "$", "options", "[", "'value'", "]", ";", "unset", "(", "$", "options", "[", "'value'", "]", ")", ";", "$", "options", "=", "$", "this", "->", "_initInputField", "(", "$", "fieldName", ",", "$", "options", ")", ";", "$", "options", "[", "'value'", "]", "=", "$", "value", ";", "$", "output", "=", "''", ";", "if", "(", "$", "options", "[", "'hiddenField'", "]", ")", "{", "$", "hiddenOptions", "=", "[", "'name'", "=>", "$", "options", "[", "'name'", "]", ",", "'value'", "=>", "(", "$", "options", "[", "'hiddenField'", "]", "!==", "true", "&&", "$", "options", "[", "'hiddenField'", "]", "!==", "'_split'", "?", "$", "options", "[", "'hiddenField'", "]", ":", "'0'", ")", ",", "'form'", "=>", "isset", "(", "$", "options", "[", "'form'", "]", ")", "?", "$", "options", "[", "'form'", "]", ":", "null", ",", "'secure'", "=>", "false", "]", ";", "if", "(", "isset", "(", "$", "options", "[", "'disabled'", "]", ")", "&&", "$", "options", "[", "'disabled'", "]", ")", "{", "$", "hiddenOptions", "[", "'disabled'", "]", "=", "'disabled'", ";", "}", "$", "output", "=", "$", "this", "->", "hidden", "(", "$", "fieldName", ",", "$", "hiddenOptions", ")", ";", "}", "if", "(", "$", "options", "[", "'hiddenField'", "]", "===", "'_split'", ")", "{", "unset", "(", "$", "options", "[", "'hiddenField'", "]", ",", "$", "options", "[", "'type'", "]", ")", ";", "return", "[", "'hidden'", "=>", "$", "output", ",", "'input'", "=>", "$", "this", "->", "widget", "(", "'checkbox'", ",", "$", "options", ")", "]", ";", "}", "unset", "(", "$", "options", "[", "'hiddenField'", "]", ",", "$", "options", "[", "'type'", "]", ")", ";", "return", "$", "output", ".", "$", "this", "->", "widget", "(", "'toggleSwitch'", ",", "$", "options", ")", ";", "}" ]
Creates a toggleSwitch input widget. ### Options: - `value` - the value of the underlaying checkbox - `checked` - boolean to indicate that this toggleSwitch is on. - `hiddenField` - boolean to indicate if you want the results of toggleSwitch() to include a hidden input with a value of ''. - `disabled` - create a disabled input. - `default` - Set the default value for the toggleSwitch. This allows you to start toggleSwitches as checked, without having to check the POST data. A matching POST data value, will overwrite the default value. @param string $fieldName Name of a field, like this "modelname.fieldname" @param array $options Array of HTML attributes. @return string|array An HTML text input element.
[ "Creates", "a", "toggleSwitch", "input", "widget", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/FormHelper.php#L153-L183
470
agalbourdin/agl-core
src/Mysql/Item.php
Item.save
public function save($pConditions = NULL) { foreach ($this->_fields as &$value) { if (is_array($value)) { $value = implode(',', $value); } } return parent::save($pConditions); }
php
public function save($pConditions = NULL) { foreach ($this->_fields as &$value) { if (is_array($value)) { $value = implode(',', $value); } } return parent::save($pConditions); }
[ "public", "function", "save", "(", "$", "pConditions", "=", "NULL", ")", "{", "foreach", "(", "$", "this", "->", "_fields", "as", "&", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "implode", "(", "','", ",", "$", "value", ")", ";", "}", "}", "return", "parent", "::", "save", "(", "$", "pConditions", ")", ";", "}" ]
Save the item in the database. @return Item
[ "Save", "the", "item", "in", "the", "database", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Mysql/Item.php#L30-L39
471
Niirrty/Niirrty.IO
src/Path.php
Path.IsAbsolute
public static function IsAbsolute( string $path, bool $dependToOS = true ) : bool { if ( \is_null( $path ) || \strlen( $path ) < 1 ) { return false; } if ( $dependToOS ) { if ( ! \IS_WIN ) { return $path[ 0 ] == '/'; } if ( \strlen( $path ) < 2 ) { return false; } return $path[ 1 ] == ':' || ( $path[ 0 ] == '\\' && $path[ 1 ] == '\\' ); } return $path[ 0 ] == '/' || $path[ 1 ] == ':' || ( $path[ 0 ] == '\\' && $path[ 1 ] == '\\' ); }
php
public static function IsAbsolute( string $path, bool $dependToOS = true ) : bool { if ( \is_null( $path ) || \strlen( $path ) < 1 ) { return false; } if ( $dependToOS ) { if ( ! \IS_WIN ) { return $path[ 0 ] == '/'; } if ( \strlen( $path ) < 2 ) { return false; } return $path[ 1 ] == ':' || ( $path[ 0 ] == '\\' && $path[ 1 ] == '\\' ); } return $path[ 0 ] == '/' || $path[ 1 ] == ':' || ( $path[ 0 ] == '\\' && $path[ 1 ] == '\\' ); }
[ "public", "static", "function", "IsAbsolute", "(", "string", "$", "path", ",", "bool", "$", "dependToOS", "=", "true", ")", ":", "bool", "{", "if", "(", "\\", "is_null", "(", "$", "path", ")", "||", "\\", "strlen", "(", "$", "path", ")", "<", "1", ")", "{", "return", "false", ";", "}", "if", "(", "$", "dependToOS", ")", "{", "if", "(", "!", "\\", "IS_WIN", ")", "{", "return", "$", "path", "[", "0", "]", "==", "'/'", ";", "}", "if", "(", "\\", "strlen", "(", "$", "path", ")", "<", "2", ")", "{", "return", "false", ";", "}", "return", "$", "path", "[", "1", "]", "==", "':'", "||", "(", "$", "path", "[", "0", "]", "==", "'\\\\'", "&&", "$", "path", "[", "1", "]", "==", "'\\\\'", ")", ";", "}", "return", "$", "path", "[", "0", "]", "==", "'/'", "||", "$", "path", "[", "1", "]", "==", "':'", "||", "(", "$", "path", "[", "0", "]", "==", "'\\\\'", "&&", "$", "path", "[", "1", "]", "==", "'\\\\'", ")", ";", "}" ]
Returns if the defined path is a absolute path definition. @param string $path @param boolean $dependToOS @return boolean
[ "Returns", "if", "the", "defined", "path", "is", "a", "absolute", "path", "definition", "." ]
13a19de41d3002d76771b3f2c85a1158a863a78e
https://github.com/Niirrty/Niirrty.IO/blob/13a19de41d3002d76771b3f2c85a1158a863a78e/src/Path.php#L123-L142
472
easy-system/es-view
src/Listener/InjectModuleListener.php
InjectModuleListener.resolveModule
protected function resolveModule($controller) { $modules = $this->getModules(); $module = get_class($controller); while (false !== $pos = strrpos($module, '\\')) { $module = substr($module, 0, $pos); if ($modules->has($module)) { return $module; } } throw new RuntimeException(sprintf( 'Failed to resolve the module namespace of the "%s" controller.', get_class($controller) )); }
php
protected function resolveModule($controller) { $modules = $this->getModules(); $module = get_class($controller); while (false !== $pos = strrpos($module, '\\')) { $module = substr($module, 0, $pos); if ($modules->has($module)) { return $module; } } throw new RuntimeException(sprintf( 'Failed to resolve the module namespace of the "%s" controller.', get_class($controller) )); }
[ "protected", "function", "resolveModule", "(", "$", "controller", ")", "{", "$", "modules", "=", "$", "this", "->", "getModules", "(", ")", ";", "$", "module", "=", "get_class", "(", "$", "controller", ")", ";", "while", "(", "false", "!==", "$", "pos", "=", "strrpos", "(", "$", "module", ",", "'\\\\'", ")", ")", "{", "$", "module", "=", "substr", "(", "$", "module", ",", "0", ",", "$", "pos", ")", ";", "if", "(", "$", "modules", "->", "has", "(", "$", "module", ")", ")", "{", "return", "$", "module", ";", "}", "}", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Failed to resolve the module namespace of the \"%s\" controller.'", ",", "get_class", "(", "$", "controller", ")", ")", ")", ";", "}" ]
Resolves the module namespace of received controller. @param object $controller The controller @throws \RuntimeException If failed to resolve the module namespace @return string The module namespace
[ "Resolves", "the", "module", "namespace", "of", "received", "controller", "." ]
8a29efcef8cd59640c98f5440379a93d0f504212
https://github.com/easy-system/es-view/blob/8a29efcef8cd59640c98f5440379a93d0f504212/src/Listener/InjectModuleListener.php#L73-L89
473
oschildt/SmartFactory
src/SmartFactory/JsonApiRequestManager.php
JsonApiRequestManager.sendJsonResponse
public function sendJsonResponse(&$response_data, $headers = []) { header('Content-type: application/json'); if (!empty($headers)) { if (is_array($headers)) { foreach ($headers as $header) { header($header); } } } echo array_to_json($response_data); }
php
public function sendJsonResponse(&$response_data, $headers = []) { header('Content-type: application/json'); if (!empty($headers)) { if (is_array($headers)) { foreach ($headers as $header) { header($header); } } } echo array_to_json($response_data); }
[ "public", "function", "sendJsonResponse", "(", "&", "$", "response_data", ",", "$", "headers", "=", "[", "]", ")", "{", "header", "(", "'Content-type: application/json'", ")", ";", "if", "(", "!", "empty", "(", "$", "headers", ")", ")", "{", "if", "(", "is_array", "(", "$", "headers", ")", ")", "{", "foreach", "(", "$", "headers", "as", "$", "header", ")", "{", "header", "(", "$", "header", ")", ";", "}", "}", "}", "echo", "array_to_json", "(", "$", "response_data", ")", ";", "}" ]
This is an auxiliary function for sending the response in JSON format. @param array $response_data The array with response data. @param array $headers The array of additional headers if necessary. The header 'Content-type: application/json' is sent automatically and need not be listed explicitly. @return void @author Oleg Schildt
[ "This", "is", "an", "auxiliary", "function", "for", "sending", "the", "response", "in", "JSON", "format", "." ]
efd289961a720d5f3103a3c696e2beee16e9644d
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/JsonApiRequestManager.php#L75-L88
474
oschildt/SmartFactory
src/SmartFactory/JsonApiRequestManager.php
JsonApiRequestManager.exitWithException
public function exitWithException($ex) { $response_data = []; $response_data["result"] = "error"; $response_data["errors"] = [ ["error_code" => "system_error", "error_text" => $ex->getMessage()] ]; $this->sendJsonResponse($response_data); exit; }
php
public function exitWithException($ex) { $response_data = []; $response_data["result"] = "error"; $response_data["errors"] = [ ["error_code" => "system_error", "error_text" => $ex->getMessage()] ]; $this->sendJsonResponse($response_data); exit; }
[ "public", "function", "exitWithException", "(", "$", "ex", ")", "{", "$", "response_data", "=", "[", "]", ";", "$", "response_data", "[", "\"result\"", "]", "=", "\"error\"", ";", "$", "response_data", "[", "\"errors\"", "]", "=", "[", "[", "\"error_code\"", "=>", "\"system_error\"", ",", "\"error_text\"", "=>", "$", "ex", "->", "getMessage", "(", ")", "]", "]", ";", "$", "this", "->", "sendJsonResponse", "(", "$", "response_data", ")", ";", "exit", ";", "}" ]
This is an auxiliary function for sending the response in JSON format by an exception. @param \Exception $ex The thrown exception. @return void @author Oleg Schildt
[ "This", "is", "an", "auxiliary", "function", "for", "sending", "the", "response", "in", "JSON", "format", "by", "an", "exception", "." ]
efd289961a720d5f3103a3c696e2beee16e9644d
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/JsonApiRequestManager.php#L101-L114
475
oschildt/SmartFactory
src/SmartFactory/JsonApiRequestManager.php
JsonApiRequestManager.getApiRequest
public function getApiRequest() { if (empty($_SERVER['REQUEST_URI'])) { return ""; } $api_request = $_SERVER['REQUEST_URI']; if (!empty($_SERVER['QUERY_STRING'])) { $api_request = str_replace($_SERVER['QUERY_STRING'], "", $api_request); } $api_request = rtrim($api_request, "/?"); $api_base = str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']); $api_base = rtrim($api_base, "/"); //echo $api_request . "<br>"; //echo $api_base . "<br>"; return trim(str_replace($api_base, "", $api_request), "/"); }
php
public function getApiRequest() { if (empty($_SERVER['REQUEST_URI'])) { return ""; } $api_request = $_SERVER['REQUEST_URI']; if (!empty($_SERVER['QUERY_STRING'])) { $api_request = str_replace($_SERVER['QUERY_STRING'], "", $api_request); } $api_request = rtrim($api_request, "/?"); $api_base = str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']); $api_base = rtrim($api_base, "/"); //echo $api_request . "<br>"; //echo $api_base . "<br>"; return trim(str_replace($api_base, "", $api_request), "/"); }
[ "public", "function", "getApiRequest", "(", ")", "{", "if", "(", "empty", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", ")", "{", "return", "\"\"", ";", "}", "$", "api_request", "=", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ";", "if", "(", "!", "empty", "(", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ")", ")", "{", "$", "api_request", "=", "str_replace", "(", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ",", "\"\"", ",", "$", "api_request", ")", ";", "}", "$", "api_request", "=", "rtrim", "(", "$", "api_request", ",", "\"/?\"", ")", ";", "$", "api_base", "=", "str_replace", "(", "basename", "(", "$", "_SERVER", "[", "'SCRIPT_NAME'", "]", ")", ",", "\"\"", ",", "$", "_SERVER", "[", "'SCRIPT_NAME'", "]", ")", ";", "$", "api_base", "=", "rtrim", "(", "$", "api_base", ",", "\"/\"", ")", ";", "//echo $api_request . \"<br>\";", "//echo $api_base . \"<br>\";", "return", "trim", "(", "str_replace", "(", "$", "api_base", ",", "\"\"", ",", "$", "api_request", ")", ",", "\"/\"", ")", ";", "}" ]
Defines the current API request name. @return string Returns the current API request. @author Oleg Schildt
[ "Defines", "the", "current", "API", "request", "name", "." ]
efd289961a720d5f3103a3c696e2beee16e9644d
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/JsonApiRequestManager.php#L124-L146
476
oschildt/SmartFactory
src/SmartFactory/JsonApiRequestManager.php
JsonApiRequestManager.registerApiRequestHandler
public function registerApiRequestHandler($api_request, $handler_class_name) { if (empty($api_request)) { throw new \Exception("The API request is undefined (empty)!"); } if (!empty($this->handler_table[$api_request])) { throw new \Exception("The API request '$api_request' has already the handler '" . $this->handler_table[$api_request] . "'!"); } $this->handler_table[$api_request] = $handler_class_name; return true; }
php
public function registerApiRequestHandler($api_request, $handler_class_name) { if (empty($api_request)) { throw new \Exception("The API request is undefined (empty)!"); } if (!empty($this->handler_table[$api_request])) { throw new \Exception("The API request '$api_request' has already the handler '" . $this->handler_table[$api_request] . "'!"); } $this->handler_table[$api_request] = $handler_class_name; return true; }
[ "public", "function", "registerApiRequestHandler", "(", "$", "api_request", ",", "$", "handler_class_name", ")", "{", "if", "(", "empty", "(", "$", "api_request", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"The API request is undefined (empty)!\"", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "handler_table", "[", "$", "api_request", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"The API request '$api_request' has already the handler '\"", ".", "$", "this", "->", "handler_table", "[", "$", "api_request", "]", ".", "\"'!\"", ")", ";", "}", "$", "this", "->", "handler_table", "[", "$", "api_request", "]", "=", "$", "handler_class_name", ";", "return", "true", ";", "}" ]
Registers a handler action for an API request call. @param string $api_request The target API request. @param string $handler_class_name The name of the class for handling this API request. Important! It should be a name of the class, neither the class instance nor the class object. It is done to prevent situation that a wrong registration of a handler breaks the handling of all requests. The class instantiating and class loading occurs only if this API request comes. @return boolean Returns true if the registration was successfull, otherwise false. @throws \Exception It might throw the following exceptions in the case of any errors: - if the request name is not specified. - if the request already has a handler. @see registerPreProcessHandler() @see registerPostProcessHandler() @see registerDefaultHandler() @author Oleg Schildt
[ "Registers", "a", "handler", "action", "for", "an", "API", "request", "call", "." ]
efd289961a720d5f3103a3c696e2beee16e9644d
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/JsonApiRequestManager.php#L179-L192
477
Dhii/expression-renderer-abstract
src/RenderExpressionAndTermsCapableTrait.php
RenderExpressionAndTermsCapableTrait._renderExpressionAndTerms
protected function _renderExpressionAndTerms(ExpressionInterface $expression, $context = null) { $renderedTerms = []; foreach ($expression->getTerms() as $_term) { $renderedTerms[] = $this->_renderExpressionTerm($_term, $context); } return $this->_compileExpressionTerms($expression, $renderedTerms, $context); }
php
protected function _renderExpressionAndTerms(ExpressionInterface $expression, $context = null) { $renderedTerms = []; foreach ($expression->getTerms() as $_term) { $renderedTerms[] = $this->_renderExpressionTerm($_term, $context); } return $this->_compileExpressionTerms($expression, $renderedTerms, $context); }
[ "protected", "function", "_renderExpressionAndTerms", "(", "ExpressionInterface", "$", "expression", ",", "$", "context", "=", "null", ")", "{", "$", "renderedTerms", "=", "[", "]", ";", "foreach", "(", "$", "expression", "->", "getTerms", "(", ")", "as", "$", "_term", ")", "{", "$", "renderedTerms", "[", "]", "=", "$", "this", "->", "_renderExpressionTerm", "(", "$", "_term", ",", "$", "context", ")", ";", "}", "return", "$", "this", "->", "_compileExpressionTerms", "(", "$", "expression", ",", "$", "renderedTerms", ",", "$", "context", ")", ";", "}" ]
Renders a given expression and its terms. @since [*next-version*] @param ExpressionInterface $expression The expression instance to render. @param array|ArrayAccess|stdClass|ContainerInterface|null $context The context. @return string|Stringable The rendered expression.
[ "Renders", "a", "given", "expression", "and", "its", "terms", "." ]
8c315e1d034b4198a89e0157f045e4a0d6cc8de8
https://github.com/Dhii/expression-renderer-abstract/blob/8c315e1d034b4198a89e0157f045e4a0d6cc8de8/src/RenderExpressionAndTermsCapableTrait.php#L33-L42
478
undefined-exception-coders/UECMediaBundle
Form/FormFactory.php
FormFactory.getFormName
public function getFormName($data) { $context = $data; if ($data instanceof MediaCommonInterface) { if ($data instanceof MediaProviderInterface) { $context = $data->getMedia()->getContext(); } else { $context = $data->getContext(); } } return $this->providerService->getProviderManager($context)->getFormName(); }
php
public function getFormName($data) { $context = $data; if ($data instanceof MediaCommonInterface) { if ($data instanceof MediaProviderInterface) { $context = $data->getMedia()->getContext(); } else { $context = $data->getContext(); } } return $this->providerService->getProviderManager($context)->getFormName(); }
[ "public", "function", "getFormName", "(", "$", "data", ")", "{", "$", "context", "=", "$", "data", ";", "if", "(", "$", "data", "instanceof", "MediaCommonInterface", ")", "{", "if", "(", "$", "data", "instanceof", "MediaProviderInterface", ")", "{", "$", "context", "=", "$", "data", "->", "getMedia", "(", ")", "->", "getContext", "(", ")", ";", "}", "else", "{", "$", "context", "=", "$", "data", "->", "getContext", "(", ")", ";", "}", "}", "return", "$", "this", "->", "providerService", "->", "getProviderManager", "(", "$", "context", ")", "->", "getFormName", "(", ")", ";", "}" ]
Get form name @param string|MediaCommonInterface $data @return string
[ "Get", "form", "name" ]
93c7bd6b3e1185ef716c26368677c08f95200f0b
https://github.com/undefined-exception-coders/UECMediaBundle/blob/93c7bd6b3e1185ef716c26368677c08f95200f0b/Form/FormFactory.php#L43-L56
479
undefined-exception-coders/UECMediaBundle
Form/FormFactory.php
FormFactory.getFormByContext
public function getFormByContext($context, array $options = array()) { $formName = $this->providerService->getProviderManager($context)->getFormName(); $mediaProvider = $this->mediaService->create($context); return $this->getForm($formName, $mediaProvider, $options); }
php
public function getFormByContext($context, array $options = array()) { $formName = $this->providerService->getProviderManager($context)->getFormName(); $mediaProvider = $this->mediaService->create($context); return $this->getForm($formName, $mediaProvider, $options); }
[ "public", "function", "getFormByContext", "(", "$", "context", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "formName", "=", "$", "this", "->", "providerService", "->", "getProviderManager", "(", "$", "context", ")", "->", "getFormName", "(", ")", ";", "$", "mediaProvider", "=", "$", "this", "->", "mediaService", "->", "create", "(", "$", "context", ")", ";", "return", "$", "this", "->", "getForm", "(", "$", "formName", ",", "$", "mediaProvider", ",", "$", "options", ")", ";", "}" ]
Get form by the context @param string $context @param array $options @return \Symfony\Component\Form\Form
[ "Get", "form", "by", "the", "context" ]
93c7bd6b3e1185ef716c26368677c08f95200f0b
https://github.com/undefined-exception-coders/UECMediaBundle/blob/93c7bd6b3e1185ef716c26368677c08f95200f0b/Form/FormFactory.php#L65-L71
480
undefined-exception-coders/UECMediaBundle
Form/FormFactory.php
FormFactory.getFormByMediaProvider
public function getFormByMediaProvider(MediaProviderInterface $mediaProvider, array $options = array()) { $formName = $this->providerService->getProviderManager($mediaProvider->getMedia()->getContext())->getFormName(); return $this->getForm($formName, $mediaProvider, $options); }
php
public function getFormByMediaProvider(MediaProviderInterface $mediaProvider, array $options = array()) { $formName = $this->providerService->getProviderManager($mediaProvider->getMedia()->getContext())->getFormName(); return $this->getForm($formName, $mediaProvider, $options); }
[ "public", "function", "getFormByMediaProvider", "(", "MediaProviderInterface", "$", "mediaProvider", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "formName", "=", "$", "this", "->", "providerService", "->", "getProviderManager", "(", "$", "mediaProvider", "->", "getMedia", "(", ")", "->", "getContext", "(", ")", ")", "->", "getFormName", "(", ")", ";", "return", "$", "this", "->", "getForm", "(", "$", "formName", ",", "$", "mediaProvider", ",", "$", "options", ")", ";", "}" ]
Get form by mediaProvider @param MediaProviderInterface $mediaProvider @param array $options @return \Symfony\Component\Form\Form
[ "Get", "form", "by", "mediaProvider" ]
93c7bd6b3e1185ef716c26368677c08f95200f0b
https://github.com/undefined-exception-coders/UECMediaBundle/blob/93c7bd6b3e1185ef716c26368677c08f95200f0b/Form/FormFactory.php#L80-L84
481
undefined-exception-coders/UECMediaBundle
Form/FormFactory.php
FormFactory.getForm
protected function getForm($formName, MediaProviderInterface $mediaProvider, array $options = array()) { return $this->formFactory->createBuilder($formName, $mediaProvider, $options)->getForm(); }
php
protected function getForm($formName, MediaProviderInterface $mediaProvider, array $options = array()) { return $this->formFactory->createBuilder($formName, $mediaProvider, $options)->getForm(); }
[ "protected", "function", "getForm", "(", "$", "formName", ",", "MediaProviderInterface", "$", "mediaProvider", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "formFactory", "->", "createBuilder", "(", "$", "formName", ",", "$", "mediaProvider", ",", "$", "options", ")", "->", "getForm", "(", ")", ";", "}" ]
Return the Form instance @param string $formName @param MediaProviderInterface $mediaProvider @param array $options @return \Symfony\Component\Form\Form
[ "Return", "the", "Form", "instance" ]
93c7bd6b3e1185ef716c26368677c08f95200f0b
https://github.com/undefined-exception-coders/UECMediaBundle/blob/93c7bd6b3e1185ef716c26368677c08f95200f0b/Form/FormFactory.php#L94-L97
482
dlapps/consul-php-envvar
src/Service/ConsulEnvManager.php
ConsulEnvManager.getEnvVarsFromConsul
public function getEnvVarsFromConsul(array $mappings) { foreach ($mappings as $environmentKey => $consulPath) { $keyExists = $this->keyIsDefined($environmentKey); if ($keyExists && !$this->overwriteEvenIfDefined) { continue; } $consulValue = $this->getKeyValueFromConsul($consulPath); $this->saveKeyValueInEnvironmentVars($environmentKey, $consulValue); } }
php
public function getEnvVarsFromConsul(array $mappings) { foreach ($mappings as $environmentKey => $consulPath) { $keyExists = $this->keyIsDefined($environmentKey); if ($keyExists && !$this->overwriteEvenIfDefined) { continue; } $consulValue = $this->getKeyValueFromConsul($consulPath); $this->saveKeyValueInEnvironmentVars($environmentKey, $consulValue); } }
[ "public", "function", "getEnvVarsFromConsul", "(", "array", "$", "mappings", ")", "{", "foreach", "(", "$", "mappings", "as", "$", "environmentKey", "=>", "$", "consulPath", ")", "{", "$", "keyExists", "=", "$", "this", "->", "keyIsDefined", "(", "$", "environmentKey", ")", ";", "if", "(", "$", "keyExists", "&&", "!", "$", "this", "->", "overwriteEvenIfDefined", ")", "{", "continue", ";", "}", "$", "consulValue", "=", "$", "this", "->", "getKeyValueFromConsul", "(", "$", "consulPath", ")", ";", "$", "this", "->", "saveKeyValueInEnvironmentVars", "(", "$", "environmentKey", ",", "$", "consulValue", ")", ";", "}", "}" ]
Add missing environment variables from Consul. @param array $mappings
[ "Add", "missing", "environment", "variables", "from", "Consul", "." ]
e5da3a3e56536c1108c32c1148cda0b589ad7773
https://github.com/dlapps/consul-php-envvar/blob/e5da3a3e56536c1108c32c1148cda0b589ad7773/src/Service/ConsulEnvManager.php#L44-L55
483
dlapps/consul-php-envvar
src/Service/ConsulEnvManager.php
ConsulEnvManager.exposeEnvironmentIntoContainer
public function exposeEnvironmentIntoContainer(ContainerBuilder $container, array $mappings): ContainerBuilder { foreach ($mappings as $environmentKey => $consulPath) { $container->setParameter("env({$environmentKey})", getenv($environmentKey)); } return $container; }
php
public function exposeEnvironmentIntoContainer(ContainerBuilder $container, array $mappings): ContainerBuilder { foreach ($mappings as $environmentKey => $consulPath) { $container->setParameter("env({$environmentKey})", getenv($environmentKey)); } return $container; }
[ "public", "function", "exposeEnvironmentIntoContainer", "(", "ContainerBuilder", "$", "container", ",", "array", "$", "mappings", ")", ":", "ContainerBuilder", "{", "foreach", "(", "$", "mappings", "as", "$", "environmentKey", "=>", "$", "consulPath", ")", "{", "$", "container", "->", "setParameter", "(", "\"env({$environmentKey})\"", ",", "getenv", "(", "$", "environmentKey", ")", ")", ";", "}", "return", "$", "container", ";", "}" ]
Expose a set of mappings into the container builder. @param ContainerBuilder $container @param array $mappings @return ContainerBuilder
[ "Expose", "a", "set", "of", "mappings", "into", "the", "container", "builder", "." ]
e5da3a3e56536c1108c32c1148cda0b589ad7773
https://github.com/dlapps/consul-php-envvar/blob/e5da3a3e56536c1108c32c1148cda0b589ad7773/src/Service/ConsulEnvManager.php#L65-L72
484
dlapps/consul-php-envvar
src/Service/ConsulEnvManager.php
ConsulEnvManager.keyIsDefined
private function keyIsDefined(string $environmentKey): bool { $keyValue = getenv($environmentKey); if (false === $keyValue) { return false; } return true; }
php
private function keyIsDefined(string $environmentKey): bool { $keyValue = getenv($environmentKey); if (false === $keyValue) { return false; } return true; }
[ "private", "function", "keyIsDefined", "(", "string", "$", "environmentKey", ")", ":", "bool", "{", "$", "keyValue", "=", "getenv", "(", "$", "environmentKey", ")", ";", "if", "(", "false", "===", "$", "keyValue", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if an environment key is defined. @param string $environmentKey @return bool
[ "Check", "if", "an", "environment", "key", "is", "defined", "." ]
e5da3a3e56536c1108c32c1148cda0b589ad7773
https://github.com/dlapps/consul-php-envvar/blob/e5da3a3e56536c1108c32c1148cda0b589ad7773/src/Service/ConsulEnvManager.php#L81-L90
485
dlapps/consul-php-envvar
src/Service/ConsulEnvManager.php
ConsulEnvManager.getKeyValueFromConsul
private function getKeyValueFromConsul(string $kvPath): string { return $this->kv->get($kvPath, ['raw' => true])->getBody(); }
php
private function getKeyValueFromConsul(string $kvPath): string { return $this->kv->get($kvPath, ['raw' => true])->getBody(); }
[ "private", "function", "getKeyValueFromConsul", "(", "string", "$", "kvPath", ")", ":", "string", "{", "return", "$", "this", "->", "kv", "->", "get", "(", "$", "kvPath", ",", "[", "'raw'", "=>", "true", "]", ")", "->", "getBody", "(", ")", ";", "}" ]
Get a key value from Consul. @param string $kvPath @return string
[ "Get", "a", "key", "value", "from", "Consul", "." ]
e5da3a3e56536c1108c32c1148cda0b589ad7773
https://github.com/dlapps/consul-php-envvar/blob/e5da3a3e56536c1108c32c1148cda0b589ad7773/src/Service/ConsulEnvManager.php#L99-L102
486
dellirom/yii2-contacts-send-tools
components/PhpMailer.php
phpmailer.Send
function Send() { if(count($this->to) < 1) { $this->error_handler("You must provide at least one recipient email address"); return false; } // Set whether the message is multipart/alternative if(!empty($this->AltBody)) $this->ContentType = "multipart/alternative"; $header = $this->create_header(); if(!$body = $this->create_body()) return false; //echo "<pre>".$header . $body . "</pre>"; // debugging // Choose the mailer if($this->Mailer == "sendmail") { if(!$this->sendmail_send($header, $body)) return false; } elseif($this->Mailer == "mail") { if(!$this->mail_send($header, $body)) return false; } elseif($this->Mailer == "smtp") { if(!$this->smtp_send($header, $body)) return false; } else { $this->error_handler(sprintf("%s mailer is not supported", $this->Mailer)); return false; } return true; }
php
function Send() { if(count($this->to) < 1) { $this->error_handler("You must provide at least one recipient email address"); return false; } // Set whether the message is multipart/alternative if(!empty($this->AltBody)) $this->ContentType = "multipart/alternative"; $header = $this->create_header(); if(!$body = $this->create_body()) return false; //echo "<pre>".$header . $body . "</pre>"; // debugging // Choose the mailer if($this->Mailer == "sendmail") { if(!$this->sendmail_send($header, $body)) return false; } elseif($this->Mailer == "mail") { if(!$this->mail_send($header, $body)) return false; } elseif($this->Mailer == "smtp") { if(!$this->smtp_send($header, $body)) return false; } else { $this->error_handler(sprintf("%s mailer is not supported", $this->Mailer)); return false; } return true; }
[ "function", "Send", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "to", ")", "<", "1", ")", "{", "$", "this", "->", "error_handler", "(", "\"You must provide at least one recipient email address\"", ")", ";", "return", "false", ";", "}", "// Set whether the message is multipart/alternative", "if", "(", "!", "empty", "(", "$", "this", "->", "AltBody", ")", ")", "$", "this", "->", "ContentType", "=", "\"multipart/alternative\"", ";", "$", "header", "=", "$", "this", "->", "create_header", "(", ")", ";", "if", "(", "!", "$", "body", "=", "$", "this", "->", "create_body", "(", ")", ")", "return", "false", ";", "//echo \"<pre>\".$header . $body . \"</pre>\"; // debugging", "// Choose the mailer", "if", "(", "$", "this", "->", "Mailer", "==", "\"sendmail\"", ")", "{", "if", "(", "!", "$", "this", "->", "sendmail_send", "(", "$", "header", ",", "$", "body", ")", ")", "return", "false", ";", "}", "elseif", "(", "$", "this", "->", "Mailer", "==", "\"mail\"", ")", "{", "if", "(", "!", "$", "this", "->", "mail_send", "(", "$", "header", ",", "$", "body", ")", ")", "return", "false", ";", "}", "elseif", "(", "$", "this", "->", "Mailer", "==", "\"smtp\"", ")", "{", "if", "(", "!", "$", "this", "->", "smtp_send", "(", "$", "header", ",", "$", "body", ")", ")", "return", "false", ";", "}", "else", "{", "$", "this", "->", "error_handler", "(", "sprintf", "(", "\"%s mailer is not supported\"", ",", "$", "this", "->", "Mailer", ")", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Creates message and assigns Mailer. If the message is not sent successfully then it returns false. Returns bool. @public @returns bool
[ "Creates", "message", "and", "assigns", "Mailer", ".", "If", "the", "message", "is", "not", "sent", "successfully", "then", "it", "returns", "false", ".", "Returns", "bool", "." ]
038c8b2cc8acee9ec4408573512d2c38d885ec1c
https://github.com/dellirom/yii2-contacts-send-tools/blob/038c8b2cc8acee9ec4408573512d2c38d885ec1c/components/PhpMailer.php#L401-L438
487
dellirom/yii2-contacts-send-tools
components/PhpMailer.php
phpmailer.addr_append
function addr_append($type, $addr) { $addr_str = ""; $addr_str .= sprintf("%s: %s <%s>", $type, $addr[0][1], $addr[0][0]); if(count($addr) > 1) { for($i = 1; $i < count($addr); $i++) { $addr_str .= sprintf(", %s <%s>", $addr[$i][1], $addr[$i][0]); } $addr_str .= "\r\n"; } else $addr_str .= "\r\n"; return($addr_str); }
php
function addr_append($type, $addr) { $addr_str = ""; $addr_str .= sprintf("%s: %s <%s>", $type, $addr[0][1], $addr[0][0]); if(count($addr) > 1) { for($i = 1; $i < count($addr); $i++) { $addr_str .= sprintf(", %s <%s>", $addr[$i][1], $addr[$i][0]); } $addr_str .= "\r\n"; } else $addr_str .= "\r\n"; return($addr_str); }
[ "function", "addr_append", "(", "$", "type", ",", "$", "addr", ")", "{", "$", "addr_str", "=", "\"\"", ";", "$", "addr_str", ".=", "sprintf", "(", "\"%s: %s <%s>\"", ",", "$", "type", ",", "$", "addr", "[", "0", "]", "[", "1", "]", ",", "$", "addr", "[", "0", "]", "[", "0", "]", ")", ";", "if", "(", "count", "(", "$", "addr", ")", ">", "1", ")", "{", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "count", "(", "$", "addr", ")", ";", "$", "i", "++", ")", "{", "$", "addr_str", ".=", "sprintf", "(", "\", %s <%s>\"", ",", "$", "addr", "[", "$", "i", "]", "[", "1", "]", ",", "$", "addr", "[", "$", "i", "]", "[", "0", "]", ")", ";", "}", "$", "addr_str", ".=", "\"\\r\\n\"", ";", "}", "else", "$", "addr_str", ".=", "\"\\r\\n\"", ";", "return", "(", "$", "addr_str", ")", ";", "}" ]
Creates recipient headers. Returns string. @private @returns string
[ "Creates", "recipient", "headers", ".", "Returns", "string", "." ]
038c8b2cc8acee9ec4408573512d2c38d885ec1c
https://github.com/dellirom/yii2-contacts-send-tools/blob/038c8b2cc8acee9ec4408573512d2c38d885ec1c/components/PhpMailer.php#L585-L600
488
dellirom/yii2-contacts-send-tools
components/PhpMailer.php
phpmailer.create_header
function create_header() { $header = array(); $header[] = sprintf("Date: %s\r\n", $this->rfc_date()); // To be created automatically by mail() if($this->Mailer != "mail") $header[] = $this->addr_append("To", $this->to); $header[] = sprintf("From: %s <%s>\r\n", $this->FromName, trim($this->From)); if(count($this->cc) > 0) $header[] = $this->addr_append("Cc", $this->cc); // sendmail and mail() extract Bcc from the header before sending if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0)) $header[] = $this->addr_append("Bcc", $this->bcc); if(count($this->ReplyTo) > 0) $header[] = $this->addr_append("Reply-to", $this->ReplyTo); // mail() sets the subject itself if($this->Mailer != "mail") $header[] = sprintf("Subject: %s\r\n", trim($this->Subject)); $header[] = sprintf("X-Priority: %d\r\n", $this->Priority); $header[] = sprintf("X-Mailer: phpmailer [version %s]\r\n", $this->Version); $header[] = sprintf("Return-Path: %s\r\n", trim($this->From)); // Add custom headers for($index = 0; $index < count($this->CustomHeader); $index++) $header[] = sprintf("%s\r\n", $this->CustomHeader[$index]); if($this->UseMSMailHeaders) $header[] = $this->AddMSMailHeaders(); $header[] = "MIME-Version: 1.0\r\n"; // Add all attachments if(count($this->attachment) > 0 || !empty($this->AltBody)) { // Set message boundary $this->boundary = "_b" . md5(uniqid(time())); // Set message subboundary for multipart/alternative $this->subboundary = "_sb" . md5(uniqid(time())); $header[] = "Content-Type: Multipart/Mixed;\r\n"; $header[] = sprintf(" boundary=\"Boundary-=%s\"\r\n\r\n", $this->boundary); } else { $header[] = sprintf("Content-Transfer-Encoding: %s\r\n", $this->Encoding); $header[] = sprintf("Content-Type: %s; charset = \"%s\"\r\n\r\n", $this->ContentType, $this->CharSet); } return(join("", $header)); }
php
function create_header() { $header = array(); $header[] = sprintf("Date: %s\r\n", $this->rfc_date()); // To be created automatically by mail() if($this->Mailer != "mail") $header[] = $this->addr_append("To", $this->to); $header[] = sprintf("From: %s <%s>\r\n", $this->FromName, trim($this->From)); if(count($this->cc) > 0) $header[] = $this->addr_append("Cc", $this->cc); // sendmail and mail() extract Bcc from the header before sending if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0)) $header[] = $this->addr_append("Bcc", $this->bcc); if(count($this->ReplyTo) > 0) $header[] = $this->addr_append("Reply-to", $this->ReplyTo); // mail() sets the subject itself if($this->Mailer != "mail") $header[] = sprintf("Subject: %s\r\n", trim($this->Subject)); $header[] = sprintf("X-Priority: %d\r\n", $this->Priority); $header[] = sprintf("X-Mailer: phpmailer [version %s]\r\n", $this->Version); $header[] = sprintf("Return-Path: %s\r\n", trim($this->From)); // Add custom headers for($index = 0; $index < count($this->CustomHeader); $index++) $header[] = sprintf("%s\r\n", $this->CustomHeader[$index]); if($this->UseMSMailHeaders) $header[] = $this->AddMSMailHeaders(); $header[] = "MIME-Version: 1.0\r\n"; // Add all attachments if(count($this->attachment) > 0 || !empty($this->AltBody)) { // Set message boundary $this->boundary = "_b" . md5(uniqid(time())); // Set message subboundary for multipart/alternative $this->subboundary = "_sb" . md5(uniqid(time())); $header[] = "Content-Type: Multipart/Mixed;\r\n"; $header[] = sprintf(" boundary=\"Boundary-=%s\"\r\n\r\n", $this->boundary); } else { $header[] = sprintf("Content-Transfer-Encoding: %s\r\n", $this->Encoding); $header[] = sprintf("Content-Type: %s; charset = \"%s\"\r\n\r\n", $this->ContentType, $this->CharSet); } return(join("", $header)); }
[ "function", "create_header", "(", ")", "{", "$", "header", "=", "array", "(", ")", ";", "$", "header", "[", "]", "=", "sprintf", "(", "\"Date: %s\\r\\n\"", ",", "$", "this", "->", "rfc_date", "(", ")", ")", ";", "// To be created automatically by mail()", "if", "(", "$", "this", "->", "Mailer", "!=", "\"mail\"", ")", "$", "header", "[", "]", "=", "$", "this", "->", "addr_append", "(", "\"To\"", ",", "$", "this", "->", "to", ")", ";", "$", "header", "[", "]", "=", "sprintf", "(", "\"From: %s <%s>\\r\\n\"", ",", "$", "this", "->", "FromName", ",", "trim", "(", "$", "this", "->", "From", ")", ")", ";", "if", "(", "count", "(", "$", "this", "->", "cc", ")", ">", "0", ")", "$", "header", "[", "]", "=", "$", "this", "->", "addr_append", "(", "\"Cc\"", ",", "$", "this", "->", "cc", ")", ";", "// sendmail and mail() extract Bcc from the header before sending", "if", "(", "(", "(", "$", "this", "->", "Mailer", "==", "\"sendmail\"", ")", "||", "(", "$", "this", "->", "Mailer", "==", "\"mail\"", ")", ")", "&&", "(", "count", "(", "$", "this", "->", "bcc", ")", ">", "0", ")", ")", "$", "header", "[", "]", "=", "$", "this", "->", "addr_append", "(", "\"Bcc\"", ",", "$", "this", "->", "bcc", ")", ";", "if", "(", "count", "(", "$", "this", "->", "ReplyTo", ")", ">", "0", ")", "$", "header", "[", "]", "=", "$", "this", "->", "addr_append", "(", "\"Reply-to\"", ",", "$", "this", "->", "ReplyTo", ")", ";", "// mail() sets the subject itself", "if", "(", "$", "this", "->", "Mailer", "!=", "\"mail\"", ")", "$", "header", "[", "]", "=", "sprintf", "(", "\"Subject: %s\\r\\n\"", ",", "trim", "(", "$", "this", "->", "Subject", ")", ")", ";", "$", "header", "[", "]", "=", "sprintf", "(", "\"X-Priority: %d\\r\\n\"", ",", "$", "this", "->", "Priority", ")", ";", "$", "header", "[", "]", "=", "sprintf", "(", "\"X-Mailer: phpmailer [version %s]\\r\\n\"", ",", "$", "this", "->", "Version", ")", ";", "$", "header", "[", "]", "=", "sprintf", "(", "\"Return-Path: %s\\r\\n\"", ",", "trim", "(", "$", "this", "->", "From", ")", ")", ";", "// Add custom headers", "for", "(", "$", "index", "=", "0", ";", "$", "index", "<", "count", "(", "$", "this", "->", "CustomHeader", ")", ";", "$", "index", "++", ")", "$", "header", "[", "]", "=", "sprintf", "(", "\"%s\\r\\n\"", ",", "$", "this", "->", "CustomHeader", "[", "$", "index", "]", ")", ";", "if", "(", "$", "this", "->", "UseMSMailHeaders", ")", "$", "header", "[", "]", "=", "$", "this", "->", "AddMSMailHeaders", "(", ")", ";", "$", "header", "[", "]", "=", "\"MIME-Version: 1.0\\r\\n\"", ";", "// Add all attachments", "if", "(", "count", "(", "$", "this", "->", "attachment", ")", ">", "0", "||", "!", "empty", "(", "$", "this", "->", "AltBody", ")", ")", "{", "// Set message boundary", "$", "this", "->", "boundary", "=", "\"_b\"", ".", "md5", "(", "uniqid", "(", "time", "(", ")", ")", ")", ";", "// Set message subboundary for multipart/alternative", "$", "this", "->", "subboundary", "=", "\"_sb\"", ".", "md5", "(", "uniqid", "(", "time", "(", ")", ")", ")", ";", "$", "header", "[", "]", "=", "\"Content-Type: Multipart/Mixed;\\r\\n\"", ";", "$", "header", "[", "]", "=", "sprintf", "(", "\" boundary=\\\"Boundary-=%s\\\"\\r\\n\\r\\n\"", ",", "$", "this", "->", "boundary", ")", ";", "}", "else", "{", "$", "header", "[", "]", "=", "sprintf", "(", "\"Content-Transfer-Encoding: %s\\r\\n\"", ",", "$", "this", "->", "Encoding", ")", ";", "$", "header", "[", "]", "=", "sprintf", "(", "\"Content-Type: %s; charset = \\\"%s\\\"\\r\\n\\r\\n\"", ",", "$", "this", "->", "ContentType", ",", "$", "this", "->", "CharSet", ")", ";", "}", "return", "(", "join", "(", "\"\"", ",", "$", "header", ")", ")", ";", "}" ]
Assembles message header. Returns a string if successful or false if unsuccessful. @private @returns string
[ "Assembles", "message", "header", ".", "Returns", "a", "string", "if", "successful", "or", "false", "if", "unsuccessful", "." ]
038c8b2cc8acee9ec4408573512d2c38d885ec1c
https://github.com/dellirom/yii2-contacts-send-tools/blob/038c8b2cc8acee9ec4408573512d2c38d885ec1c/components/PhpMailer.php#L693-L748
489
dellirom/yii2-contacts-send-tools
components/PhpMailer.php
phpmailer.create_body
function create_body() { // wordwrap the message body if set if($this->WordWrap) $this->Body = $this->wordwrap($this->Body, $this->WordWrap); // If content type is multipart/alternative set body like this: if ((!empty($this->AltBody)) && (count($this->attachment) < 1)) { // Return text of body $mime = array(); $mime[] = "This is a MIME message. If you are reading this text, you\r\n"; $mime[] = "might want to consider changing to a mail reader that\r\n"; $mime[] = "understands how to properly display MIME multipart messages.\r\n\r\n"; $mime[] = sprintf("--Boundary-=%s\r\n", $this->boundary); // Insert body. If multipart/alternative, insert both html and plain $mime[] = sprintf("Content-Type: %s; charset = \"%s\"; boundary = \"Boundary-=%s\";\r\n", $this->ContentType, $this->CharSet, $this->subboundary); $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding); $mime[] = sprintf("--Boundary-=%s\r\n", $this->subboundary); $mime[] = sprintf("Content-Type: text/html; charset = \"%s\";\r\n", $this->CharSet); $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding); $mime[] = sprintf("%s\r\n\r\n", $this->Body); $mime[] = sprintf("--Boundary-=%s\r\n", $this->subboundary); $mime[] = sprintf("Content-Type: text/plain; charset = \"%s\";\r\n", $this->CharSet); $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding); $mime[] = sprintf("%s\r\n\r\n", $this->AltBody); $mime[] = sprintf("\r\n--Boundary-=%s--\r\n\r\n", $this->subboundary); $mime[] = sprintf("\r\n--Boundary-=%s--\r\n", $this->boundary); $this->Body = $this->encode_string(join("", $mime), $this->Encoding); } else { $this->Body = $this->encode_string($this->Body, $this->Encoding); } if(count($this->attachment) > 0) { if(!$body = $this->attach_all()) return false; } else $body = $this->Body; return($body); }
php
function create_body() { // wordwrap the message body if set if($this->WordWrap) $this->Body = $this->wordwrap($this->Body, $this->WordWrap); // If content type is multipart/alternative set body like this: if ((!empty($this->AltBody)) && (count($this->attachment) < 1)) { // Return text of body $mime = array(); $mime[] = "This is a MIME message. If you are reading this text, you\r\n"; $mime[] = "might want to consider changing to a mail reader that\r\n"; $mime[] = "understands how to properly display MIME multipart messages.\r\n\r\n"; $mime[] = sprintf("--Boundary-=%s\r\n", $this->boundary); // Insert body. If multipart/alternative, insert both html and plain $mime[] = sprintf("Content-Type: %s; charset = \"%s\"; boundary = \"Boundary-=%s\";\r\n", $this->ContentType, $this->CharSet, $this->subboundary); $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding); $mime[] = sprintf("--Boundary-=%s\r\n", $this->subboundary); $mime[] = sprintf("Content-Type: text/html; charset = \"%s\";\r\n", $this->CharSet); $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding); $mime[] = sprintf("%s\r\n\r\n", $this->Body); $mime[] = sprintf("--Boundary-=%s\r\n", $this->subboundary); $mime[] = sprintf("Content-Type: text/plain; charset = \"%s\";\r\n", $this->CharSet); $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding); $mime[] = sprintf("%s\r\n\r\n", $this->AltBody); $mime[] = sprintf("\r\n--Boundary-=%s--\r\n\r\n", $this->subboundary); $mime[] = sprintf("\r\n--Boundary-=%s--\r\n", $this->boundary); $this->Body = $this->encode_string(join("", $mime), $this->Encoding); } else { $this->Body = $this->encode_string($this->Body, $this->Encoding); } if(count($this->attachment) > 0) { if(!$body = $this->attach_all()) return false; } else $body = $this->Body; return($body); }
[ "function", "create_body", "(", ")", "{", "// wordwrap the message body if set", "if", "(", "$", "this", "->", "WordWrap", ")", "$", "this", "->", "Body", "=", "$", "this", "->", "wordwrap", "(", "$", "this", "->", "Body", ",", "$", "this", "->", "WordWrap", ")", ";", "// If content type is multipart/alternative set body like this:", "if", "(", "(", "!", "empty", "(", "$", "this", "->", "AltBody", ")", ")", "&&", "(", "count", "(", "$", "this", "->", "attachment", ")", "<", "1", ")", ")", "{", "// Return text of body", "$", "mime", "=", "array", "(", ")", ";", "$", "mime", "[", "]", "=", "\"This is a MIME message. If you are reading this text, you\\r\\n\"", ";", "$", "mime", "[", "]", "=", "\"might want to consider changing to a mail reader that\\r\\n\"", ";", "$", "mime", "[", "]", "=", "\"understands how to properly display MIME multipart messages.\\r\\n\\r\\n\"", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"--Boundary-=%s\\r\\n\"", ",", "$", "this", "->", "boundary", ")", ";", "// Insert body. If multipart/alternative, insert both html and plain", "$", "mime", "[", "]", "=", "sprintf", "(", "\"Content-Type: %s; charset = \\\"%s\\\"; boundary = \\\"Boundary-=%s\\\";\\r\\n\"", ",", "$", "this", "->", "ContentType", ",", "$", "this", "->", "CharSet", ",", "$", "this", "->", "subboundary", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"Content-Transfer-Encoding: %s\\r\\n\\r\\n\"", ",", "$", "this", "->", "Encoding", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"--Boundary-=%s\\r\\n\"", ",", "$", "this", "->", "subboundary", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"Content-Type: text/html; charset = \\\"%s\\\";\\r\\n\"", ",", "$", "this", "->", "CharSet", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"Content-Transfer-Encoding: %s\\r\\n\\r\\n\"", ",", "$", "this", "->", "Encoding", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"%s\\r\\n\\r\\n\"", ",", "$", "this", "->", "Body", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"--Boundary-=%s\\r\\n\"", ",", "$", "this", "->", "subboundary", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"Content-Type: text/plain; charset = \\\"%s\\\";\\r\\n\"", ",", "$", "this", "->", "CharSet", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"Content-Transfer-Encoding: %s\\r\\n\\r\\n\"", ",", "$", "this", "->", "Encoding", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"%s\\r\\n\\r\\n\"", ",", "$", "this", "->", "AltBody", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"\\r\\n--Boundary-=%s--\\r\\n\\r\\n\"", ",", "$", "this", "->", "subboundary", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"\\r\\n--Boundary-=%s--\\r\\n\"", ",", "$", "this", "->", "boundary", ")", ";", "$", "this", "->", "Body", "=", "$", "this", "->", "encode_string", "(", "join", "(", "\"\"", ",", "$", "mime", ")", ",", "$", "this", "->", "Encoding", ")", ";", "}", "else", "{", "$", "this", "->", "Body", "=", "$", "this", "->", "encode_string", "(", "$", "this", "->", "Body", ",", "$", "this", "->", "Encoding", ")", ";", "}", "if", "(", "count", "(", "$", "this", "->", "attachment", ")", ">", "0", ")", "{", "if", "(", "!", "$", "body", "=", "$", "this", "->", "attach_all", "(", ")", ")", "return", "false", ";", "}", "else", "$", "body", "=", "$", "this", "->", "Body", ";", "return", "(", "$", "body", ")", ";", "}" ]
Assembles the message body. Returns a string if successful or false if unsuccessful. @private @returns string
[ "Assembles", "the", "message", "body", ".", "Returns", "a", "string", "if", "successful", "or", "false", "if", "unsuccessful", "." ]
038c8b2cc8acee9ec4408573512d2c38d885ec1c
https://github.com/dellirom/yii2-contacts-send-tools/blob/038c8b2cc8acee9ec4408573512d2c38d885ec1c/components/PhpMailer.php#L756-L807
490
dellirom/yii2-contacts-send-tools
components/PhpMailer.php
phpmailer.AddAttachment
function AddAttachment($path, $name = "", $encoding = "base64", $type = "application/octet-stream") { if(!@is_file($path)) { $this->error_handler(sprintf("Could not find %s file on filesystem", $path)); return false; } $filename = basename($path); if($name == "") $name = $filename; // Append to $attachment array $cur = count($this->attachment); $this->attachment[$cur][0] = $path; $this->attachment[$cur][1] = $filename; $this->attachment[$cur][2] = $name; $this->attachment[$cur][3] = $encoding; $this->attachment[$cur][4] = $type; $this->attachment[$cur][5] = false; // isStringAttachment return true; }
php
function AddAttachment($path, $name = "", $encoding = "base64", $type = "application/octet-stream") { if(!@is_file($path)) { $this->error_handler(sprintf("Could not find %s file on filesystem", $path)); return false; } $filename = basename($path); if($name == "") $name = $filename; // Append to $attachment array $cur = count($this->attachment); $this->attachment[$cur][0] = $path; $this->attachment[$cur][1] = $filename; $this->attachment[$cur][2] = $name; $this->attachment[$cur][3] = $encoding; $this->attachment[$cur][4] = $type; $this->attachment[$cur][5] = false; // isStringAttachment return true; }
[ "function", "AddAttachment", "(", "$", "path", ",", "$", "name", "=", "\"\"", ",", "$", "encoding", "=", "\"base64\"", ",", "$", "type", "=", "\"application/octet-stream\"", ")", "{", "if", "(", "!", "@", "is_file", "(", "$", "path", ")", ")", "{", "$", "this", "->", "error_handler", "(", "sprintf", "(", "\"Could not find %s file on filesystem\"", ",", "$", "path", ")", ")", ";", "return", "false", ";", "}", "$", "filename", "=", "basename", "(", "$", "path", ")", ";", "if", "(", "$", "name", "==", "\"\"", ")", "$", "name", "=", "$", "filename", ";", "// Append to $attachment array", "$", "cur", "=", "count", "(", "$", "this", "->", "attachment", ")", ";", "$", "this", "->", "attachment", "[", "$", "cur", "]", "[", "0", "]", "=", "$", "path", ";", "$", "this", "->", "attachment", "[", "$", "cur", "]", "[", "1", "]", "=", "$", "filename", ";", "$", "this", "->", "attachment", "[", "$", "cur", "]", "[", "2", "]", "=", "$", "name", ";", "$", "this", "->", "attachment", "[", "$", "cur", "]", "[", "3", "]", "=", "$", "encoding", ";", "$", "this", "->", "attachment", "[", "$", "cur", "]", "[", "4", "]", "=", "$", "type", ";", "$", "this", "->", "attachment", "[", "$", "cur", "]", "[", "5", "]", "=", "false", ";", "// isStringAttachment", "return", "true", ";", "}" ]
Adds an attachment from the OS filesystem. Checks if attachment is valid and then adds the attachment to the list. Returns false if the file was not found. @public @returns bool
[ "Adds", "an", "attachment", "from", "the", "OS", "filesystem", ".", "Checks", "if", "attachment", "is", "valid", "and", "then", "adds", "the", "attachment", "to", "the", "list", ".", "Returns", "false", "if", "the", "file", "was", "not", "found", "." ]
038c8b2cc8acee9ec4408573512d2c38d885ec1c
https://github.com/dellirom/yii2-contacts-send-tools/blob/038c8b2cc8acee9ec4408573512d2c38d885ec1c/components/PhpMailer.php#L822-L843
491
dellirom/yii2-contacts-send-tools
components/PhpMailer.php
phpmailer.encode_file
function encode_file ($path, $encoding = "base64") { if(!@$fd = fopen($path, "rb")) { $this->error_handler(sprintf("File Error: Could not open file %s", $path)); return false; } $file = fread($fd, filesize($path)); $encoded = $this->encode_string($file, $encoding); fclose($fd); return($encoded); }
php
function encode_file ($path, $encoding = "base64") { if(!@$fd = fopen($path, "rb")) { $this->error_handler(sprintf("File Error: Could not open file %s", $path)); return false; } $file = fread($fd, filesize($path)); $encoded = $this->encode_string($file, $encoding); fclose($fd); return($encoded); }
[ "function", "encode_file", "(", "$", "path", ",", "$", "encoding", "=", "\"base64\"", ")", "{", "if", "(", "!", "@", "$", "fd", "=", "fopen", "(", "$", "path", ",", "\"rb\"", ")", ")", "{", "$", "this", "->", "error_handler", "(", "sprintf", "(", "\"File Error: Could not open file %s\"", ",", "$", "path", ")", ")", ";", "return", "false", ";", "}", "$", "file", "=", "fread", "(", "$", "fd", ",", "filesize", "(", "$", "path", ")", ")", ";", "$", "encoded", "=", "$", "this", "->", "encode_string", "(", "$", "file", ",", "$", "encoding", ")", ";", "fclose", "(", "$", "fd", ")", ";", "return", "(", "$", "encoded", ")", ";", "}" ]
Encodes attachment in requested format. Returns a string if successful or false if unsuccessful. @private @returns string
[ "Encodes", "attachment", "in", "requested", "format", ".", "Returns", "a", "string", "if", "successful", "or", "false", "if", "unsuccessful", "." ]
038c8b2cc8acee9ec4408573512d2c38d885ec1c
https://github.com/dellirom/yii2-contacts-send-tools/blob/038c8b2cc8acee9ec4408573512d2c38d885ec1c/components/PhpMailer.php#L935-L946
492
dellirom/yii2-contacts-send-tools
components/PhpMailer.php
phpmailer.encode_string
function encode_string ($str, $encoding = "base64") { switch(strtolower($encoding)) { case "base64": // chunk_split is found in PHP >= 3.0.6 $encoded = chunk_split(base64_encode($str)); break; case "7bit": case "8bit": $encoded = $this->fix_eol($str); if (substr($encoded, -2) != "\r\n") $encoded .= "\r\n"; break; case "binary": $encoded = $str; break; case "quoted-printable": $encoded = $this->encode_qp($str); break; default: $this->error_handler(sprintf("Unknown encoding: %s", $encoding)); return false; } return($encoded); }
php
function encode_string ($str, $encoding = "base64") { switch(strtolower($encoding)) { case "base64": // chunk_split is found in PHP >= 3.0.6 $encoded = chunk_split(base64_encode($str)); break; case "7bit": case "8bit": $encoded = $this->fix_eol($str); if (substr($encoded, -2) != "\r\n") $encoded .= "\r\n"; break; case "binary": $encoded = $str; break; case "quoted-printable": $encoded = $this->encode_qp($str); break; default: $this->error_handler(sprintf("Unknown encoding: %s", $encoding)); return false; } return($encoded); }
[ "function", "encode_string", "(", "$", "str", ",", "$", "encoding", "=", "\"base64\"", ")", "{", "switch", "(", "strtolower", "(", "$", "encoding", ")", ")", "{", "case", "\"base64\"", ":", "// chunk_split is found in PHP >= 3.0.6", "$", "encoded", "=", "chunk_split", "(", "base64_encode", "(", "$", "str", ")", ")", ";", "break", ";", "case", "\"7bit\"", ":", "case", "\"8bit\"", ":", "$", "encoded", "=", "$", "this", "->", "fix_eol", "(", "$", "str", ")", ";", "if", "(", "substr", "(", "$", "encoded", ",", "-", "2", ")", "!=", "\"\\r\\n\"", ")", "$", "encoded", ".=", "\"\\r\\n\"", ";", "break", ";", "case", "\"binary\"", ":", "$", "encoded", "=", "$", "str", ";", "break", ";", "case", "\"quoted-printable\"", ":", "$", "encoded", "=", "$", "this", "->", "encode_qp", "(", "$", "str", ")", ";", "break", ";", "default", ":", "$", "this", "->", "error_handler", "(", "sprintf", "(", "\"Unknown encoding: %s\"", ",", "$", "encoding", ")", ")", ";", "return", "false", ";", "}", "return", "(", "$", "encoded", ")", ";", "}" ]
Encodes string to requested format. Returns a string if successful or false if unsuccessful. @private @returns string
[ "Encodes", "string", "to", "requested", "format", ".", "Returns", "a", "string", "if", "successful", "or", "false", "if", "unsuccessful", "." ]
038c8b2cc8acee9ec4408573512d2c38d885ec1c
https://github.com/dellirom/yii2-contacts-send-tools/blob/038c8b2cc8acee9ec4408573512d2c38d885ec1c/components/PhpMailer.php#L954-L981
493
dellirom/yii2-contacts-send-tools
components/PhpMailer.php
phpmailer.rfc_date
function rfc_date() { $tz = date("Z"); $tzs = ($tz < 0) ? "-" : "+"; $tz = abs($tz); $tz = ($tz/3600)*100 + ($tz%3600)/60; $date = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz); return $date; }
php
function rfc_date() { $tz = date("Z"); $tzs = ($tz < 0) ? "-" : "+"; $tz = abs($tz); $tz = ($tz/3600)*100 + ($tz%3600)/60; $date = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz); return $date; }
[ "function", "rfc_date", "(", ")", "{", "$", "tz", "=", "date", "(", "\"Z\"", ")", ";", "$", "tzs", "=", "(", "$", "tz", "<", "0", ")", "?", "\"-\"", ":", "\"+\"", ";", "$", "tz", "=", "abs", "(", "$", "tz", ")", ";", "$", "tz", "=", "(", "$", "tz", "/", "3600", ")", "*", "100", "+", "(", "$", "tz", "%", "3600", ")", "/", "60", ";", "$", "date", "=", "sprintf", "(", "\"%s %s%04d\"", ",", "date", "(", "\"D, j M Y H:i:s\"", ")", ",", "$", "tzs", ",", "$", "tz", ")", ";", "return", "$", "date", ";", "}" ]
Returns the proper RFC 822 formatted date. Returns string. @private @returns string
[ "Returns", "the", "proper", "RFC", "822", "formatted", "date", ".", "Returns", "string", "." ]
038c8b2cc8acee9ec4408573512d2c38d885ec1c
https://github.com/dellirom/yii2-contacts-send-tools/blob/038c8b2cc8acee9ec4408573512d2c38d885ec1c/components/PhpMailer.php#L1115-L1122
494
dellirom/yii2-contacts-send-tools
components/PhpMailer.php
phpmailer.fix_eol
function fix_eol($str) { $str = str_replace("\r\n", "\n", $str); $str = str_replace("\r", "\n", $str); $str = str_replace("\n", "\r\n", $str); return $str; }
php
function fix_eol($str) { $str = str_replace("\r\n", "\n", $str); $str = str_replace("\r", "\n", $str); $str = str_replace("\n", "\r\n", $str); return $str; }
[ "function", "fix_eol", "(", "$", "str", ")", "{", "$", "str", "=", "str_replace", "(", "\"\\r\\n\"", ",", "\"\\n\"", ",", "$", "str", ")", ";", "$", "str", "=", "str_replace", "(", "\"\\r\"", ",", "\"\\n\"", ",", "$", "str", ")", ";", "$", "str", "=", "str_replace", "(", "\"\\n\"", ",", "\"\\r\\n\"", ",", "$", "str", ")", ";", "return", "$", "str", ";", "}" ]
Changes every end of line from CR or LF to CRLF. Returns string. @private @returns string
[ "Changes", "every", "end", "of", "line", "from", "CR", "or", "LF", "to", "CRLF", ".", "Returns", "string", "." ]
038c8b2cc8acee9ec4408573512d2c38d885ec1c
https://github.com/dellirom/yii2-contacts-send-tools/blob/038c8b2cc8acee9ec4408573512d2c38d885ec1c/components/PhpMailer.php#L1129-L1134
495
dellirom/yii2-contacts-send-tools
components/PhpMailer.php
phpmailer.AddMSMailHeaders
function AddMSMailHeaders() { $MSHeader = ""; if($this->Priority == 1) $MSPriority = "High"; elseif($this->Priority == 5) $MSPriority = "Low"; else $MSPriority = "Medium"; $MSHeader .= sprintf("X-MSMail-Priority: %s\r\n", $MSPriority); $MSHeader .= sprintf("Importance: %s\r\n", $MSPriority); return($MSHeader); }
php
function AddMSMailHeaders() { $MSHeader = ""; if($this->Priority == 1) $MSPriority = "High"; elseif($this->Priority == 5) $MSPriority = "Low"; else $MSPriority = "Medium"; $MSHeader .= sprintf("X-MSMail-Priority: %s\r\n", $MSPriority); $MSHeader .= sprintf("Importance: %s\r\n", $MSPriority); return($MSHeader); }
[ "function", "AddMSMailHeaders", "(", ")", "{", "$", "MSHeader", "=", "\"\"", ";", "if", "(", "$", "this", "->", "Priority", "==", "1", ")", "$", "MSPriority", "=", "\"High\"", ";", "elseif", "(", "$", "this", "->", "Priority", "==", "5", ")", "$", "MSPriority", "=", "\"Low\"", ";", "else", "$", "MSPriority", "=", "\"Medium\"", ";", "$", "MSHeader", ".=", "sprintf", "(", "\"X-MSMail-Priority: %s\\r\\n\"", ",", "$", "MSPriority", ")", ";", "$", "MSHeader", ".=", "sprintf", "(", "\"Importance: %s\\r\\n\"", ",", "$", "MSPriority", ")", ";", "return", "(", "$", "MSHeader", ")", ";", "}" ]
Adds all the Microsoft message headers. Returns string. @private @returns string
[ "Adds", "all", "the", "Microsoft", "message", "headers", ".", "Returns", "string", "." ]
038c8b2cc8acee9ec4408573512d2c38d885ec1c
https://github.com/dellirom/yii2-contacts-send-tools/blob/038c8b2cc8acee9ec4408573512d2c38d885ec1c/components/PhpMailer.php#L1150-L1163
496
vend/pheat
src/Feature/RatioFeature.php
RatioFeature.context
public function context(ContextInterface $context) { if (!empty($this->vary)) { $this->varyValue = $context->get($this->vary); } }
php
public function context(ContextInterface $context) { if (!empty($this->vary)) { $this->varyValue = $context->get($this->vary); } }
[ "public", "function", "context", "(", "ContextInterface", "$", "context", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "vary", ")", ")", "{", "$", "this", "->", "varyValue", "=", "$", "context", "->", "get", "(", "$", "this", "->", "vary", ")", ";", "}", "}" ]
We assume pack format specifier 'I' is equal in size to PHP_INT_SIZE @param ContextInterface $context
[ "We", "assume", "pack", "format", "specifier", "I", "is", "equal", "in", "size", "to", "PHP_INT_SIZE" ]
381acc1a3aeb3b3574bd50b183836388ab7ac161
https://github.com/vend/pheat/blob/381acc1a3aeb3b3574bd50b183836388ab7ac161/src/Feature/RatioFeature.php#L68-L73
497
vend/pheat
src/Feature/RatioFeature.php
RatioFeature.getRatioStatus
protected function getRatioStatus() { if ($this->ratio == 0.0) { return Status::INACTIVE; } if ($this->ratio >= 1.0) { return Status::ACTIVE; } $value = unpack('nint', md5((string)$this->varyValue, true))['int']; $filter = (int)floor(self::RESOLUTION * (float)$this->ratio); return ($value < $filter); }
php
protected function getRatioStatus() { if ($this->ratio == 0.0) { return Status::INACTIVE; } if ($this->ratio >= 1.0) { return Status::ACTIVE; } $value = unpack('nint', md5((string)$this->varyValue, true))['int']; $filter = (int)floor(self::RESOLUTION * (float)$this->ratio); return ($value < $filter); }
[ "protected", "function", "getRatioStatus", "(", ")", "{", "if", "(", "$", "this", "->", "ratio", "==", "0.0", ")", "{", "return", "Status", "::", "INACTIVE", ";", "}", "if", "(", "$", "this", "->", "ratio", ">=", "1.0", ")", "{", "return", "Status", "::", "ACTIVE", ";", "}", "$", "value", "=", "unpack", "(", "'nint'", ",", "md5", "(", "(", "string", ")", "$", "this", "->", "varyValue", ",", "true", ")", ")", "[", "'int'", "]", ";", "$", "filter", "=", "(", "int", ")", "floor", "(", "self", "::", "RESOLUTION", "*", "(", "float", ")", "$", "this", "->", "ratio", ")", ";", "return", "(", "$", "value", "<", "$", "filter", ")", ";", "}" ]
Gets whether the feature is enabled according to the ratio alone A RatioFeature can be enabled and disabled like any other feature. Only when it is enabled, with a ratio above 0, does the ratio actually come into play. We assume 0 <= $this->varyValue <= self::RESOLUTION when entering, uniformly distributed. @return boolean|null
[ "Gets", "whether", "the", "feature", "is", "enabled", "according", "to", "the", "ratio", "alone" ]
381acc1a3aeb3b3574bd50b183836388ab7ac161
https://github.com/vend/pheat/blob/381acc1a3aeb3b3574bd50b183836388ab7ac161/src/Feature/RatioFeature.php#L86-L100
498
canis-io/yii2-key-provider
lib/providers/FlysystemProvider.php
FlysystemProvider.setAdapter
public function setAdapter($adapter) { if (is_array($adapter)) { $adapter = Yii::createObject($adapter); } if (interface_exists('League\Flysystem\AdapterInterface') && $adapter instanceof AdapterInterface) { $this->adapter = $adapter; } else { throw new InaccessibleKeyPairException("Flysystem adapter for retrieving the key pair is invalid"); } }
php
public function setAdapter($adapter) { if (is_array($adapter)) { $adapter = Yii::createObject($adapter); } if (interface_exists('League\Flysystem\AdapterInterface') && $adapter instanceof AdapterInterface) { $this->adapter = $adapter; } else { throw new InaccessibleKeyPairException("Flysystem adapter for retrieving the key pair is invalid"); } }
[ "public", "function", "setAdapter", "(", "$", "adapter", ")", "{", "if", "(", "is_array", "(", "$", "adapter", ")", ")", "{", "$", "adapter", "=", "Yii", "::", "createObject", "(", "$", "adapter", ")", ";", "}", "if", "(", "interface_exists", "(", "'League\\Flysystem\\AdapterInterface'", ")", "&&", "$", "adapter", "instanceof", "AdapterInterface", ")", "{", "$", "this", "->", "adapter", "=", "$", "adapter", ";", "}", "else", "{", "throw", "new", "InaccessibleKeyPairException", "(", "\"Flysystem adapter for retrieving the key pair is invalid\"", ")", ";", "}", "}" ]
Sets the adapter to use for the provider @param \League\Flysystem\AdapterInterface|array $adapter The Flysystem adapter to use for the provider
[ "Sets", "the", "adapter", "to", "use", "for", "the", "provider" ]
c54f1c8af812bddf48872a05bc1d1e02112decc9
https://github.com/canis-io/yii2-key-provider/blob/c54f1c8af812bddf48872a05bc1d1e02112decc9/lib/providers/FlysystemProvider.php#L37-L47
499
rseyferth/chickenwire
src/ChickenWire/Module.php
Module.load
public static function load($name, $options = array()) { // Module already loaded? if (array_key_exists($name, self::$_modules)) { throw new \Exception("A module with the name $name has already been loaded.", 1); } // Create and add $module = new Module($name, $options); self::$_modules[$name] = $module; return $module; }
php
public static function load($name, $options = array()) { // Module already loaded? if (array_key_exists($name, self::$_modules)) { throw new \Exception("A module with the name $name has already been loaded.", 1); } // Create and add $module = new Module($name, $options); self::$_modules[$name] = $module; return $module; }
[ "public", "static", "function", "load", "(", "$", "name", ",", "$", "options", "=", "array", "(", ")", ")", "{", "// Module already loaded?", "if", "(", "array_key_exists", "(", "$", "name", ",", "self", "::", "$", "_modules", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"A module with the name $name has already been loaded.\"", ",", "1", ")", ";", "}", "// Create and add", "$", "module", "=", "new", "Module", "(", "$", "name", ",", "$", "options", ")", ";", "self", "::", "$", "_modules", "[", "$", "name", "]", "=", "$", "module", ";", "return", "$", "module", ";", "}" ]
Load a Module @param string The name of the Module @param array Array of options to apply to the Module (see above). @return \ChickenWire\Module The created Module instance
[ "Load", "a", "Module" ]
74921f0a0d489366602e25df43eda894719e43d3
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Module.php#L110-L122