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
8,400
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/email/classes/email/driver/mandrill.php
Email_Driver_Mandrill.add_merge_vars
public function add_merge_vars(array $merge_vars, $rcpt = null) { if (is_null($rcpt)) { $this->merge_vars = $merge_vars; } else { $this->rcpt_merge_vars[$rcpt] = $merge_vars; } return $this; }
php
public function add_merge_vars(array $merge_vars, $rcpt = null) { if (is_null($rcpt)) { $this->merge_vars = $merge_vars; } else { $this->rcpt_merge_vars[$rcpt] = $merge_vars; } return $this; }
[ "public", "function", "add_merge_vars", "(", "array", "$", "merge_vars", ",", "$", "rcpt", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "rcpt", ")", ")", "{", "$", "this", "->", "merge_vars", "=", "$", "merge_vars", ";", "}", "else", "{", "$", "this", "->", "rcpt_merge_vars", "[", "$", "rcpt", "]", "=", "$", "merge_vars", ";", "}", "return", "$", "this", ";", "}" ]
Add merge vars @param array $merge_vars Key-value pairs @param mixed $rcpt Null for global, string for recipient @return array
[ "Add", "merge", "vars" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/email/classes/email/driver/mandrill.php#L239-L251
8,401
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/email/classes/email/driver/mandrill.php
Email_Driver_Mandrill.set_merge_var
public function set_merge_var($key, $value = null, $rcpt = null) { is_array($key) or $key = array($key => $value); if (is_null($rcpt)) { $this->merge_vars = \Arr::merge($this->merge_vars, $key); } else { $merge_vars = \Arr::get($this->rcpt_merge_vars, $rcpt, array()); $this->rcpt_merge_vars[$rcpt] = \Arr::merge($merge_vars, $key); } return $this; }
php
public function set_merge_var($key, $value = null, $rcpt = null) { is_array($key) or $key = array($key => $value); if (is_null($rcpt)) { $this->merge_vars = \Arr::merge($this->merge_vars, $key); } else { $merge_vars = \Arr::get($this->rcpt_merge_vars, $rcpt, array()); $this->rcpt_merge_vars[$rcpt] = \Arr::merge($merge_vars, $key); } return $this; }
[ "public", "function", "set_merge_var", "(", "$", "key", ",", "$", "value", "=", "null", ",", "$", "rcpt", "=", "null", ")", "{", "is_array", "(", "$", "key", ")", "or", "$", "key", "=", "array", "(", "$", "key", "=>", "$", "value", ")", ";", "if", "(", "is_null", "(", "$", "rcpt", ")", ")", "{", "$", "this", "->", "merge_vars", "=", "\\", "Arr", "::", "merge", "(", "$", "this", "->", "merge_vars", ",", "$", "key", ")", ";", "}", "else", "{", "$", "merge_vars", "=", "\\", "Arr", "::", "get", "(", "$", "this", "->", "rcpt_merge_vars", ",", "$", "rcpt", ",", "array", "(", ")", ")", ";", "$", "this", "->", "rcpt_merge_vars", "[", "$", "rcpt", "]", "=", "\\", "Arr", "::", "merge", "(", "$", "merge_vars", ",", "$", "key", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set one or several merge vars @param mixed $key Array for many vars, string for one @param mixed $value In case of many vars it is ommited @param mixed $rcpt Null for global, string for recipient @return object $this
[ "Set", "one", "or", "several", "merge", "vars" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/email/classes/email/driver/mandrill.php#L261-L276
8,402
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/email/classes/email/driver/mandrill.php
Email_Driver_Mandrill.set_metadata
public function set_metadata($key, $value = null, $rcpt = null) { is_array($key) or $key = array($key => $value); if (is_null($rcpt)) { $this->metadata = \Arr::merge($this->metadata, $key); } else { $metadata = \Arr::get($this->rcpt_metadata, $rcpt, array()); $this->rcpt_metadata[$rcpt] = \Arr::merge($metadata, $key); } return $this; }
php
public function set_metadata($key, $value = null, $rcpt = null) { is_array($key) or $key = array($key => $value); if (is_null($rcpt)) { $this->metadata = \Arr::merge($this->metadata, $key); } else { $metadata = \Arr::get($this->rcpt_metadata, $rcpt, array()); $this->rcpt_metadata[$rcpt] = \Arr::merge($metadata, $key); } return $this; }
[ "public", "function", "set_metadata", "(", "$", "key", ",", "$", "value", "=", "null", ",", "$", "rcpt", "=", "null", ")", "{", "is_array", "(", "$", "key", ")", "or", "$", "key", "=", "array", "(", "$", "key", "=>", "$", "value", ")", ";", "if", "(", "is_null", "(", "$", "rcpt", ")", ")", "{", "$", "this", "->", "metadata", "=", "\\", "Arr", "::", "merge", "(", "$", "this", "->", "metadata", ",", "$", "key", ")", ";", "}", "else", "{", "$", "metadata", "=", "\\", "Arr", "::", "get", "(", "$", "this", "->", "rcpt_metadata", ",", "$", "rcpt", ",", "array", "(", ")", ")", ";", "$", "this", "->", "rcpt_metadata", "[", "$", "rcpt", "]", "=", "\\", "Arr", "::", "merge", "(", "$", "metadata", ",", "$", "key", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set one or several metadata @param mixed $key Array for many, string for one @param mixed $value In case of many it is ommited @param mixed $rcpt Null for global, string for recipient @return object $this
[ "Set", "one", "or", "several", "metadata" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/email/classes/email/driver/mandrill.php#L326-L341
8,403
atorscho/menus
src/Parser.php
Parser.parseMenuItems
private function parseMenuItems($title, string $url, array $children, array $fields): Item { $urlGenerator = $this->instantiateUrlGenerator(); // Extract parameters into variables if (is_array($title)) { extract($title); } // If child elements provided if ($children) { $childItems = []; foreach ($children as $child) { $this->checkFormat($child); // If child contains child elements, use recursively add them if (isset($child['children']) && $child['children']) { $childItems[] = $this->parseMenuItems($child['title'], $child['url'], $child['children'], $child['fields'] ?? []); } else { $childItems[] = new Item($child['title'], $child['url'], [], $child['fields'] ?? [], new Config, $urlGenerator); } } } return new Item($title, $url, $childItems ?? $children, $fields, new Config, $urlGenerator); }
php
private function parseMenuItems($title, string $url, array $children, array $fields): Item { $urlGenerator = $this->instantiateUrlGenerator(); // Extract parameters into variables if (is_array($title)) { extract($title); } // If child elements provided if ($children) { $childItems = []; foreach ($children as $child) { $this->checkFormat($child); // If child contains child elements, use recursively add them if (isset($child['children']) && $child['children']) { $childItems[] = $this->parseMenuItems($child['title'], $child['url'], $child['children'], $child['fields'] ?? []); } else { $childItems[] = new Item($child['title'], $child['url'], [], $child['fields'] ?? [], new Config, $urlGenerator); } } } return new Item($title, $url, $childItems ?? $children, $fields, new Config, $urlGenerator); }
[ "private", "function", "parseMenuItems", "(", "$", "title", ",", "string", "$", "url", ",", "array", "$", "children", ",", "array", "$", "fields", ")", ":", "Item", "{", "$", "urlGenerator", "=", "$", "this", "->", "instantiateUrlGenerator", "(", ")", ";", "// Extract parameters into variables", "if", "(", "is_array", "(", "$", "title", ")", ")", "{", "extract", "(", "$", "title", ")", ";", "}", "// If child elements provided", "if", "(", "$", "children", ")", "{", "$", "childItems", "=", "[", "]", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "this", "->", "checkFormat", "(", "$", "child", ")", ";", "// If child contains child elements, use recursively add them", "if", "(", "isset", "(", "$", "child", "[", "'children'", "]", ")", "&&", "$", "child", "[", "'children'", "]", ")", "{", "$", "childItems", "[", "]", "=", "$", "this", "->", "parseMenuItems", "(", "$", "child", "[", "'title'", "]", ",", "$", "child", "[", "'url'", "]", ",", "$", "child", "[", "'children'", "]", ",", "$", "child", "[", "'fields'", "]", "??", "[", "]", ")", ";", "}", "else", "{", "$", "childItems", "[", "]", "=", "new", "Item", "(", "$", "child", "[", "'title'", "]", ",", "$", "child", "[", "'url'", "]", ",", "[", "]", ",", "$", "child", "[", "'fields'", "]", "??", "[", "]", ",", "new", "Config", ",", "$", "urlGenerator", ")", ";", "}", "}", "}", "return", "new", "Item", "(", "$", "title", ",", "$", "url", ",", "$", "childItems", "??", "$", "children", ",", "$", "fields", ",", "new", "Config", ",", "$", "urlGenerator", ")", ";", "}" ]
Parse menu items by converting them into instances of Item.
[ "Parse", "menu", "items", "by", "converting", "them", "into", "instances", "of", "Item", "." ]
9ef049761e410018424a32e46a3360a8de1e374a
https://github.com/atorscho/menus/blob/9ef049761e410018424a32e46a3360a8de1e374a/src/Parser.php#L22-L49
8,404
infinity-se/infinity-base
src/InfinityBase/View/Helper/Messages.php
Messages._renderMessages
protected function _renderMessages(array $messages) { // Don't create list for single message if (count($messages) == 1) { return reset($messages); } // Start output $output = '<ul>'; // Loop through messages foreach ($messages as $message) { // Add message $output .= '<li>' . $message . '</li>'; } // Finish output $output .= '</ul>'; return $output; }
php
protected function _renderMessages(array $messages) { // Don't create list for single message if (count($messages) == 1) { return reset($messages); } // Start output $output = '<ul>'; // Loop through messages foreach ($messages as $message) { // Add message $output .= '<li>' . $message . '</li>'; } // Finish output $output .= '</ul>'; return $output; }
[ "protected", "function", "_renderMessages", "(", "array", "$", "messages", ")", "{", "// Don't create list for single message", "if", "(", "count", "(", "$", "messages", ")", "==", "1", ")", "{", "return", "reset", "(", "$", "messages", ")", ";", "}", "// Start output", "$", "output", "=", "'<ul>'", ";", "// Loop through messages", "foreach", "(", "$", "messages", "as", "$", "message", ")", "{", "// Add message", "$", "output", ".=", "'<li>'", ".", "$", "message", ".", "'</li>'", ";", "}", "// Finish output", "$", "output", ".=", "'</ul>'", ";", "return", "$", "output", ";", "}" ]
Render message array @param array $messages
[ "Render", "message", "array" ]
4f869ae4b549e779560a83528d2ed2664f6deb5b
https://github.com/infinity-se/infinity-base/blob/4f869ae4b549e779560a83528d2ed2664f6deb5b/src/InfinityBase/View/Helper/Messages.php#L60-L81
8,405
guru-digital/ss-gdm-extensions
code/Helpers/GridBuilder.php
GridBuilder.addBulkUploader
public function addBulkUploader($fileRelationName = null, $folderName = null) { $gridFieldBulkUpload = Injector::inst()->create("GridFieldBulkUpload", $fileRelationName); if ($folderName) { $gridFieldBulkUpload->setUfSetup("setFolderName", $folderName); } $this->gridConfig->addComponent($gridFieldBulkUpload); return $this; }
php
public function addBulkUploader($fileRelationName = null, $folderName = null) { $gridFieldBulkUpload = Injector::inst()->create("GridFieldBulkUpload", $fileRelationName); if ($folderName) { $gridFieldBulkUpload->setUfSetup("setFolderName", $folderName); } $this->gridConfig->addComponent($gridFieldBulkUpload); return $this; }
[ "public", "function", "addBulkUploader", "(", "$", "fileRelationName", "=", "null", ",", "$", "folderName", "=", "null", ")", "{", "$", "gridFieldBulkUpload", "=", "Injector", "::", "inst", "(", ")", "->", "create", "(", "\"GridFieldBulkUpload\"", ",", "$", "fileRelationName", ")", ";", "if", "(", "$", "folderName", ")", "{", "$", "gridFieldBulkUpload", "->", "setUfSetup", "(", "\"setFolderName\"", ",", "$", "folderName", ")", ";", "}", "$", "this", "->", "gridConfig", "->", "addComponent", "(", "$", "gridFieldBulkUpload", ")", ";", "return", "$", "this", ";", "}" ]
Enables bulk uploaded of files and images @param string $fileRelationName The relation name in the model to attach uploaded files to @param string $folderName Folder path to upload files to @return \GridBuilder
[ "Enables", "bulk", "uploaded", "of", "files", "and", "images" ]
0ccb29ea11b6d3b9d1f488c8eccad1a0de085c67
https://github.com/guru-digital/ss-gdm-extensions/blob/0ccb29ea11b6d3b9d1f488c8eccad1a0de085c67/code/Helpers/GridBuilder.php#L84-L92
8,406
veridu/idos-sdk-php
src/idOS/Endpoint/AbstractEndpoint.php
AbstractEndpoint.sendRequest
private function sendRequest(string $method, string $uri, array $query = [], array $body = []) : array { $uri = sprintf('%s%s', $this->baseUrl, ltrim($uri, '/')); $options = [ 'headers' => [ 'Authorization' => (string) $this->authentication ], 'http_errors' => false ]; if (! empty($query)) { $options['query'] = $query; } if (! empty($body)) { $options['json'] = $body; } $response = $this->client->request( $method, $uri, $options ); $json = json_decode((string) $response->getBody(), true); if ($json === null) { if ($this->throwsExceptions) { throw new SDKError(); } return [(string) $response->getBody()]; } if (($json['status'] === false) && ($this->throwsExceptions)) { throw new SDKException( $json['error']['message'], $json['error']['type'], $json['error']['link'] ); } return $json; }
php
private function sendRequest(string $method, string $uri, array $query = [], array $body = []) : array { $uri = sprintf('%s%s', $this->baseUrl, ltrim($uri, '/')); $options = [ 'headers' => [ 'Authorization' => (string) $this->authentication ], 'http_errors' => false ]; if (! empty($query)) { $options['query'] = $query; } if (! empty($body)) { $options['json'] = $body; } $response = $this->client->request( $method, $uri, $options ); $json = json_decode((string) $response->getBody(), true); if ($json === null) { if ($this->throwsExceptions) { throw new SDKError(); } return [(string) $response->getBody()]; } if (($json['status'] === false) && ($this->throwsExceptions)) { throw new SDKException( $json['error']['message'], $json['error']['type'], $json['error']['link'] ); } return $json; }
[ "private", "function", "sendRequest", "(", "string", "$", "method", ",", "string", "$", "uri", ",", "array", "$", "query", "=", "[", "]", ",", "array", "$", "body", "=", "[", "]", ")", ":", "array", "{", "$", "uri", "=", "sprintf", "(", "'%s%s'", ",", "$", "this", "->", "baseUrl", ",", "ltrim", "(", "$", "uri", ",", "'/'", ")", ")", ";", "$", "options", "=", "[", "'headers'", "=>", "[", "'Authorization'", "=>", "(", "string", ")", "$", "this", "->", "authentication", "]", ",", "'http_errors'", "=>", "false", "]", ";", "if", "(", "!", "empty", "(", "$", "query", ")", ")", "{", "$", "options", "[", "'query'", "]", "=", "$", "query", ";", "}", "if", "(", "!", "empty", "(", "$", "body", ")", ")", "{", "$", "options", "[", "'json'", "]", "=", "$", "body", ";", "}", "$", "response", "=", "$", "this", "->", "client", "->", "request", "(", "$", "method", ",", "$", "uri", ",", "$", "options", ")", ";", "$", "json", "=", "json_decode", "(", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "if", "(", "$", "json", "===", "null", ")", "{", "if", "(", "$", "this", "->", "throwsExceptions", ")", "{", "throw", "new", "SDKError", "(", ")", ";", "}", "return", "[", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", "]", ";", "}", "if", "(", "(", "$", "json", "[", "'status'", "]", "===", "false", ")", "&&", "(", "$", "this", "->", "throwsExceptions", ")", ")", "{", "throw", "new", "SDKException", "(", "$", "json", "[", "'error'", "]", "[", "'message'", "]", ",", "$", "json", "[", "'error'", "]", "[", "'type'", "]", ",", "$", "json", "[", "'error'", "]", "[", "'link'", "]", ")", ";", "}", "return", "$", "json", ";", "}" ]
Sends the request to the api. @param string $method @param array $query @param array $body @return array response
[ "Sends", "the", "request", "to", "the", "api", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/AbstractEndpoint.php#L47-L89
8,407
veridu/idos-sdk-php
src/idOS/Endpoint/AbstractEndpoint.php
AbstractEndpoint.sendPost
protected function sendPost(string $uri, array $query = [], array $body = []) : array { return $this->sendRequest( 'POST', $uri, $query, $body ); }
php
protected function sendPost(string $uri, array $query = [], array $body = []) : array { return $this->sendRequest( 'POST', $uri, $query, $body ); }
[ "protected", "function", "sendPost", "(", "string", "$", "uri", ",", "array", "$", "query", "=", "[", "]", ",", "array", "$", "body", "=", "[", "]", ")", ":", "array", "{", "return", "$", "this", "->", "sendRequest", "(", "'POST'", ",", "$", "uri", ",", "$", "query", ",", "$", "body", ")", ";", "}" ]
Sends a POST request. @param string $uri @param array $query @param array $body @return array response
[ "Sends", "a", "POST", "request", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/AbstractEndpoint.php#L117-L124
8,408
veridu/idos-sdk-php
src/idOS/Endpoint/AbstractEndpoint.php
AbstractEndpoint.sendPatch
protected function sendPatch(string $uri, array $query = [], array $body = []) : array { return $this->sendRequest( 'PATCH', $uri, $query, $body ); }
php
protected function sendPatch(string $uri, array $query = [], array $body = []) : array { return $this->sendRequest( 'PATCH', $uri, $query, $body ); }
[ "protected", "function", "sendPatch", "(", "string", "$", "uri", ",", "array", "$", "query", "=", "[", "]", ",", "array", "$", "body", "=", "[", "]", ")", ":", "array", "{", "return", "$", "this", "->", "sendRequest", "(", "'PATCH'", ",", "$", "uri", ",", "$", "query", ",", "$", "body", ")", ";", "}" ]
Sends a PATCH request. @param string $uri @param array $query @param array $body @return array response
[ "Sends", "a", "PATCH", "request", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/AbstractEndpoint.php#L135-L142
8,409
veridu/idos-sdk-php
src/idOS/Endpoint/AbstractEndpoint.php
AbstractEndpoint.sendPut
protected function sendPut(string $uri, array $query = [], array $body = []) : array { return $this->sendRequest( 'PUT', $uri, $query, $body ); }
php
protected function sendPut(string $uri, array $query = [], array $body = []) : array { return $this->sendRequest( 'PUT', $uri, $query, $body ); }
[ "protected", "function", "sendPut", "(", "string", "$", "uri", ",", "array", "$", "query", "=", "[", "]", ",", "array", "$", "body", "=", "[", "]", ")", ":", "array", "{", "return", "$", "this", "->", "sendRequest", "(", "'PUT'", ",", "$", "uri", ",", "$", "query", ",", "$", "body", ")", ";", "}" ]
Sends a PUT request. @param string $uri @param array $query @param array $body @return array response
[ "Sends", "a", "PUT", "request", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/AbstractEndpoint.php#L153-L160
8,410
aberdnikov/meerkat-twig
classes/Meerkat/Twig/Twig/Extension.php
Twig_Extension.getFilters
public function getFilters() { return array( // Numbers 'num_format' => new \Twig_Filter_Function('num::format'), // Text 'limit_words' => new \Twig_Filter_Function('Text::limit_words'), 'limit_chars' => new \Twig_Filter_Function('Text::limit_chars'), 'auto_link' => new \Twig_Filter_Function('Text::auto_link'), 'auto_p' => new \Twig_Filter_Function('Text::auto_p'), 'bytes' => new \Twig_Filter_Function('Text::bytes'), 'lower' => new \Twig_Filter_Function('mb_strtolower'), 'upper' => new \Twig_Filter_Function('mb_strtoupper'), 'ucfirst' => new \Twig_Filter_Function('ucfirst'), 'ucwords' => new \Twig_Filter_Function('ucwords'), 'strip_tags' => new \Twig_Filter_Function('strip_tags'), 'trim' => new \Twig_Filter_Function('trim'), 'int' => new \Twig_Filter_Function('intval'), 'xss_clean' => new \Twig_Filter_Function('Security::xss_clean'), 'urlencode' => new \Twig_Filter_Function('urlencode'), 'highlight' => new \Twig_Filter_Function('\Meerkat\Twig\Twig_Extension::f_highlight'), ); }
php
public function getFilters() { return array( // Numbers 'num_format' => new \Twig_Filter_Function('num::format'), // Text 'limit_words' => new \Twig_Filter_Function('Text::limit_words'), 'limit_chars' => new \Twig_Filter_Function('Text::limit_chars'), 'auto_link' => new \Twig_Filter_Function('Text::auto_link'), 'auto_p' => new \Twig_Filter_Function('Text::auto_p'), 'bytes' => new \Twig_Filter_Function('Text::bytes'), 'lower' => new \Twig_Filter_Function('mb_strtolower'), 'upper' => new \Twig_Filter_Function('mb_strtoupper'), 'ucfirst' => new \Twig_Filter_Function('ucfirst'), 'ucwords' => new \Twig_Filter_Function('ucwords'), 'strip_tags' => new \Twig_Filter_Function('strip_tags'), 'trim' => new \Twig_Filter_Function('trim'), 'int' => new \Twig_Filter_Function('intval'), 'xss_clean' => new \Twig_Filter_Function('Security::xss_clean'), 'urlencode' => new \Twig_Filter_Function('urlencode'), 'highlight' => new \Twig_Filter_Function('\Meerkat\Twig\Twig_Extension::f_highlight'), ); }
[ "public", "function", "getFilters", "(", ")", "{", "return", "array", "(", "// Numbers", "'num_format'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'num::format'", ")", ",", "// Text", "'limit_words'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'Text::limit_words'", ")", ",", "'limit_chars'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'Text::limit_chars'", ")", ",", "'auto_link'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'Text::auto_link'", ")", ",", "'auto_p'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'Text::auto_p'", ")", ",", "'bytes'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'Text::bytes'", ")", ",", "'lower'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'mb_strtolower'", ")", ",", "'upper'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'mb_strtoupper'", ")", ",", "'ucfirst'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'ucfirst'", ")", ",", "'ucwords'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'ucwords'", ")", ",", "'strip_tags'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'strip_tags'", ")", ",", "'trim'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'trim'", ")", ",", "'int'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'intval'", ")", ",", "'xss_clean'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'Security::xss_clean'", ")", ",", "'urlencode'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'urlencode'", ")", ",", "'highlight'", "=>", "new", "\\", "Twig_Filter_Function", "(", "'\\Meerkat\\Twig\\Twig_Extension::f_highlight'", ")", ",", ")", ";", "}" ]
Returns the added filters @return array @author Jonathan Geiger
[ "Returns", "the", "added", "filters" ]
a1d4810d5e4b917f0ea25c8d0a915bef31c81787
https://github.com/aberdnikov/meerkat-twig/blob/a1d4810d5e4b917f0ea25c8d0a915bef31c81787/classes/Meerkat/Twig/Twig/Extension.php#L195-L215
8,411
Flowpack/Flowpack.SingleSignOn.Client
Classes/Flowpack/SingleSignOn/Client/Aspect/LoggingAspect.php
LoggingAspect.logSignedRequestPatternFailures
public function logSignedRequestPatternFailures(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint) { $request = $joinPoint->getMethodArgument('request'); if ($request instanceof \TYPO3\Flow\Mvc\RequestInterface) { if ($request->getControllerObjectName() === 'Flowpack\SingleSignOn\Client\Controller\SessionController') { $this->securityLogger->log('Signature for call to Session service could not be verified', LOG_NOTICE, array( 'identifier' => $joinPoint->getMethodArgument('identifier'), 'publicKeyFingerprint' => $joinPoint->getMethodArgument('publicKeyFingerprint'), 'signature' => base64_encode($joinPoint->getMethodArgument('signature')), 'signData' => $joinPoint->getMethodArgument('signData'), 'content' => $joinPoint->getMethodArgument('request')->getHttpRequest()->getContent(), )); } } }
php
public function logSignedRequestPatternFailures(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint) { $request = $joinPoint->getMethodArgument('request'); if ($request instanceof \TYPO3\Flow\Mvc\RequestInterface) { if ($request->getControllerObjectName() === 'Flowpack\SingleSignOn\Client\Controller\SessionController') { $this->securityLogger->log('Signature for call to Session service could not be verified', LOG_NOTICE, array( 'identifier' => $joinPoint->getMethodArgument('identifier'), 'publicKeyFingerprint' => $joinPoint->getMethodArgument('publicKeyFingerprint'), 'signature' => base64_encode($joinPoint->getMethodArgument('signature')), 'signData' => $joinPoint->getMethodArgument('signData'), 'content' => $joinPoint->getMethodArgument('request')->getHttpRequest()->getContent(), )); } } }
[ "public", "function", "logSignedRequestPatternFailures", "(", "\\", "TYPO3", "\\", "Flow", "\\", "Aop", "\\", "JoinPointInterface", "$", "joinPoint", ")", "{", "$", "request", "=", "$", "joinPoint", "->", "getMethodArgument", "(", "'request'", ")", ";", "if", "(", "$", "request", "instanceof", "\\", "TYPO3", "\\", "Flow", "\\", "Mvc", "\\", "RequestInterface", ")", "{", "if", "(", "$", "request", "->", "getControllerObjectName", "(", ")", "===", "'Flowpack\\SingleSignOn\\Client\\Controller\\SessionController'", ")", "{", "$", "this", "->", "securityLogger", "->", "log", "(", "'Signature for call to Session service could not be verified'", ",", "LOG_NOTICE", ",", "array", "(", "'identifier'", "=>", "$", "joinPoint", "->", "getMethodArgument", "(", "'identifier'", ")", ",", "'publicKeyFingerprint'", "=>", "$", "joinPoint", "->", "getMethodArgument", "(", "'publicKeyFingerprint'", ")", ",", "'signature'", "=>", "base64_encode", "(", "$", "joinPoint", "->", "getMethodArgument", "(", "'signature'", ")", ")", ",", "'signData'", "=>", "$", "joinPoint", "->", "getMethodArgument", "(", "'signData'", ")", ",", "'content'", "=>", "$", "joinPoint", "->", "getMethodArgument", "(", "'request'", ")", "->", "getHttpRequest", "(", ")", "->", "getContent", "(", ")", ",", ")", ")", ";", "}", "}", "}" ]
Log signed request pattern failures @Flow\AfterReturning("setting(Flowpack.SingleSignOn.Client.log.logFailedSignedRequests) && method(Flowpack\SingleSignOn\Client\Security\RequestPattern\SignedRequestPattern->emitSignatureNotVerified())") @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current joinpoint
[ "Log", "signed", "request", "pattern", "failures" ]
0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00
https://github.com/Flowpack/Flowpack.SingleSignOn.Client/blob/0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00/Classes/Flowpack/SingleSignOn/Client/Aspect/LoggingAspect.php#L30-L43
8,412
gossi/trixionary
src/model/Base/StructureNodeQuery.php
StructureNodeQuery.filterByDescendantClass
public function filterByDescendantClass($descendantClass = null, $comparison = null) { if (null === $comparison) { if (is_array($descendantClass)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $descendantClass)) { $descendantClass = str_replace('*', '%', $descendantClass); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(StructureNodeTableMap::COL_DESCENDANT_CLASS, $descendantClass, $comparison); }
php
public function filterByDescendantClass($descendantClass = null, $comparison = null) { if (null === $comparison) { if (is_array($descendantClass)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $descendantClass)) { $descendantClass = str_replace('*', '%', $descendantClass); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(StructureNodeTableMap::COL_DESCENDANT_CLASS, $descendantClass, $comparison); }
[ "public", "function", "filterByDescendantClass", "(", "$", "descendantClass", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "descendantClass", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "descendantClass", ")", ")", "{", "$", "descendantClass", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "descendantClass", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "StructureNodeTableMap", "::", "COL_DESCENDANT_CLASS", ",", "$", "descendantClass", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the descendant_class column Example usage: <code> $query->filterByDescendantClass('fooValue'); // WHERE descendant_class = 'fooValue' $query->filterByDescendantClass('%fooValue%'); // WHERE descendant_class LIKE '%fooValue%' </code> @param string $descendantClass The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildStructureNodeQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "descendant_class", "column" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNodeQuery.php#L424-L436
8,413
gossi/trixionary
src/model/Base/StructureNodeQuery.php
StructureNodeQuery.useStructureNodeParentRelatedByStructureNodeIdQuery
public function useStructureNodeParentRelatedByStructureNodeIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinStructureNodeParentRelatedByStructureNodeId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'StructureNodeParentRelatedByStructureNodeId', '\gossi\trixionary\model\StructureNodeParentQuery'); }
php
public function useStructureNodeParentRelatedByStructureNodeIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinStructureNodeParentRelatedByStructureNodeId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'StructureNodeParentRelatedByStructureNodeId', '\gossi\trixionary\model\StructureNodeParentQuery'); }
[ "public", "function", "useStructureNodeParentRelatedByStructureNodeIdQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinStructureNodeParentRelatedByStructureNodeId", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'StructureNodeParentRelatedByStructureNodeId'", ",", "'\\gossi\\trixionary\\model\\StructureNodeParentQuery'", ")", ";", "}" ]
Use the StructureNodeParentRelatedByStructureNodeId relation StructureNodeParent object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \gossi\trixionary\model\StructureNodeParentQuery A secondary query class using the current class as primary query
[ "Use", "the", "StructureNodeParentRelatedByStructureNodeId", "relation", "StructureNodeParent", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNodeQuery.php#L581-L586
8,414
gossi/trixionary
src/model/Base/StructureNodeQuery.php
StructureNodeQuery.useStructureNodeParentRelatedByParentIdQuery
public function useStructureNodeParentRelatedByParentIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinStructureNodeParentRelatedByParentId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'StructureNodeParentRelatedByParentId', '\gossi\trixionary\model\StructureNodeParentQuery'); }
php
public function useStructureNodeParentRelatedByParentIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinStructureNodeParentRelatedByParentId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'StructureNodeParentRelatedByParentId', '\gossi\trixionary\model\StructureNodeParentQuery'); }
[ "public", "function", "useStructureNodeParentRelatedByParentIdQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinStructureNodeParentRelatedByParentId", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'StructureNodeParentRelatedByParentId'", ",", "'\\gossi\\trixionary\\model\\StructureNodeParentQuery'", ")", ";", "}" ]
Use the StructureNodeParentRelatedByParentId relation StructureNodeParent object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \gossi\trixionary\model\StructureNodeParentQuery A secondary query class using the current class as primary query
[ "Use", "the", "StructureNodeParentRelatedByParentId", "relation", "StructureNodeParent", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNodeQuery.php#L654-L659
8,415
gossi/trixionary
src/model/Base/StructureNodeQuery.php
StructureNodeQuery.useKstrukturQuery
public function useKstrukturQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinKstruktur($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Kstruktur', '\gossi\trixionary\model\KstrukturQuery'); }
php
public function useKstrukturQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinKstruktur($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Kstruktur', '\gossi\trixionary\model\KstrukturQuery'); }
[ "public", "function", "useKstrukturQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinKstruktur", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'Kstruktur'", ",", "'\\gossi\\trixionary\\model\\KstrukturQuery'", ")", ";", "}" ]
Use the Kstruktur relation Kstruktur object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \gossi\trixionary\model\KstrukturQuery A secondary query class using the current class as primary query
[ "Use", "the", "Kstruktur", "relation", "Kstruktur", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNodeQuery.php#L727-L732
8,416
gossi/trixionary
src/model/Base/StructureNodeQuery.php
StructureNodeQuery.useFunctionPhaseQuery
public function useFunctionPhaseQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinFunctionPhase($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'FunctionPhase', '\gossi\trixionary\model\FunctionPhaseQuery'); }
php
public function useFunctionPhaseQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinFunctionPhase($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'FunctionPhase', '\gossi\trixionary\model\FunctionPhaseQuery'); }
[ "public", "function", "useFunctionPhaseQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinFunctionPhase", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'FunctionPhase'", ",", "'\\gossi\\trixionary\\model\\FunctionPhaseQuery'", ")", ";", "}" ]
Use the FunctionPhase relation FunctionPhase object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \gossi\trixionary\model\FunctionPhaseQuery A secondary query class using the current class as primary query
[ "Use", "the", "FunctionPhase", "relation", "FunctionPhase", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNodeQuery.php#L800-L805
8,417
CampusUnion/Sked
src/SkeVent.php
SkeVent.getProperty
public function getProperty(string $strKey) { $mReturn = null; switch ($strKey) { // Parse weekday values case 'weekdays': $mReturn = array_keys(array_intersect_key( $this->aProperties, array_flip(self::WEEKDAYS) ), 1); break; // Calculate lead time factors case 'lead_time_num': case 'lead_time_unit': $mReturn = $this->getLeadTimeFactor($strKey); break; default: $mReturn = $this->aProperties[$strKey] ?? null; break; } return $mReturn; }
php
public function getProperty(string $strKey) { $mReturn = null; switch ($strKey) { // Parse weekday values case 'weekdays': $mReturn = array_keys(array_intersect_key( $this->aProperties, array_flip(self::WEEKDAYS) ), 1); break; // Calculate lead time factors case 'lead_time_num': case 'lead_time_unit': $mReturn = $this->getLeadTimeFactor($strKey); break; default: $mReturn = $this->aProperties[$strKey] ?? null; break; } return $mReturn; }
[ "public", "function", "getProperty", "(", "string", "$", "strKey", ")", "{", "$", "mReturn", "=", "null", ";", "switch", "(", "$", "strKey", ")", "{", "// Parse weekday values", "case", "'weekdays'", ":", "$", "mReturn", "=", "array_keys", "(", "array_intersect_key", "(", "$", "this", "->", "aProperties", ",", "array_flip", "(", "self", "::", "WEEKDAYS", ")", ")", ",", "1", ")", ";", "break", ";", "// Calculate lead time factors", "case", "'lead_time_num'", ":", "case", "'lead_time_unit'", ":", "$", "mReturn", "=", "$", "this", "->", "getLeadTimeFactor", "(", "$", "strKey", ")", ";", "break", ";", "default", ":", "$", "mReturn", "=", "$", "this", "->", "aProperties", "[", "$", "strKey", "]", "??", "null", ";", "break", ";", "}", "return", "$", "mReturn", ";", "}" ]
Get an event property by key. @param string $strKey The name of the property to get. @return mixed
[ "Get", "an", "event", "property", "by", "key", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L142-L166
8,418
CampusUnion/Sked
src/SkeVent.php
SkeVent.setProperty
public function setProperty(string $strKey, $mValue) { // Empty strings coming from an HTML form should be nullified if ('' === $mValue) $mValue = null; switch ($strKey) { // Parse weekday values case 'weekdays': $this->setWeekdays((array)$mValue); break; // Process tags case 'tags': $this->setTags($mValue); break; // Save datetimes & timezone for later case 'timezone': $this->strTimezone = $mValue; break; case 'starts_at': case 'ends_at': $strProperty = 'starts_at' === $strKey ? 'strStartsAt' : 'strEndsAt'; $this->$strProperty = $mValue; // no break, so it falls through to default default: $this->aProperties[$strKey] = $mValue; break; } }
php
public function setProperty(string $strKey, $mValue) { // Empty strings coming from an HTML form should be nullified if ('' === $mValue) $mValue = null; switch ($strKey) { // Parse weekday values case 'weekdays': $this->setWeekdays((array)$mValue); break; // Process tags case 'tags': $this->setTags($mValue); break; // Save datetimes & timezone for later case 'timezone': $this->strTimezone = $mValue; break; case 'starts_at': case 'ends_at': $strProperty = 'starts_at' === $strKey ? 'strStartsAt' : 'strEndsAt'; $this->$strProperty = $mValue; // no break, so it falls through to default default: $this->aProperties[$strKey] = $mValue; break; } }
[ "public", "function", "setProperty", "(", "string", "$", "strKey", ",", "$", "mValue", ")", "{", "// Empty strings coming from an HTML form should be nullified", "if", "(", "''", "===", "$", "mValue", ")", "$", "mValue", "=", "null", ";", "switch", "(", "$", "strKey", ")", "{", "// Parse weekday values", "case", "'weekdays'", ":", "$", "this", "->", "setWeekdays", "(", "(", "array", ")", "$", "mValue", ")", ";", "break", ";", "// Process tags", "case", "'tags'", ":", "$", "this", "->", "setTags", "(", "$", "mValue", ")", ";", "break", ";", "// Save datetimes & timezone for later", "case", "'timezone'", ":", "$", "this", "->", "strTimezone", "=", "$", "mValue", ";", "break", ";", "case", "'starts_at'", ":", "case", "'ends_at'", ":", "$", "strProperty", "=", "'starts_at'", "===", "$", "strKey", "?", "'strStartsAt'", ":", "'strEndsAt'", ";", "$", "this", "->", "$", "strProperty", "=", "$", "mValue", ";", "// no break, so it falls through to default", "default", ":", "$", "this", "->", "aProperties", "[", "$", "strKey", "]", "=", "$", "mValue", ";", "break", ";", "}", "}" ]
Set an event property by key. @param string $strKey The name of the property to set. @param mixed $mValue New value for the property.
[ "Set", "an", "event", "property", "by", "key", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L185-L217
8,419
CampusUnion/Sked
src/SkeVent.php
SkeVent.setProperties
public function setProperties(array $aProperties) { foreach ($aProperties as $strKey => $mValue) $this->setProperty($strKey, $mValue); $this->adjustDependentFields(); }
php
public function setProperties(array $aProperties) { foreach ($aProperties as $strKey => $mValue) $this->setProperty($strKey, $mValue); $this->adjustDependentFields(); }
[ "public", "function", "setProperties", "(", "array", "$", "aProperties", ")", "{", "foreach", "(", "$", "aProperties", "as", "$", "strKey", "=>", "$", "mValue", ")", "$", "this", "->", "setProperty", "(", "$", "strKey", ",", "$", "mValue", ")", ";", "$", "this", "->", "adjustDependentFields", "(", ")", ";", "}" ]
Set properties from array. @param array $aProperties
[ "Set", "properties", "from", "array", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L224-L230
8,420
CampusUnion/Sked
src/SkeVent.php
SkeVent.setWeekdays
protected function setWeekdays(array $aValues = []) { foreach (self::WEEKDAYS as $strDay) $this->setProperty($strDay, (int)in_array($strDay, $aValues)); }
php
protected function setWeekdays(array $aValues = []) { foreach (self::WEEKDAYS as $strDay) $this->setProperty($strDay, (int)in_array($strDay, $aValues)); }
[ "protected", "function", "setWeekdays", "(", "array", "$", "aValues", "=", "[", "]", ")", "{", "foreach", "(", "self", "::", "WEEKDAYS", "as", "$", "strDay", ")", "$", "this", "->", "setProperty", "(", "$", "strDay", ",", "(", "int", ")", "in_array", "(", "$", "strDay", ",", "$", "aValues", ")", ")", ";", "}" ]
Set each weekday property based on an array of weekday abbreviations. @param array $aValues List of weekday abbreviations to activate.
[ "Set", "each", "weekday", "property", "based", "on", "an", "array", "of", "weekday", "abbreviations", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L237-L241
8,421
CampusUnion/Sked
src/SkeVent.php
SkeVent.adjustDependentFields
protected function adjustDependentFields() { // Recurring-event fields if (array_key_exists('repeats', $this->aProperties) && !$this->repeats) { $this->frequency = null; $this->interval = self::INTERVAL_ONCE; $this->setWeekdays(); $this->ends_at = null; } // Datetimes & timezone if (!is_null($this->strStartsAt)) { $this->aProperties['starts_at'] = Carbon::parse($this->strStartsAt, $this->strTimezone) ->setTimezone('UTC') ->toDateTimeString(); } if (!is_null($this->strEndsAt)) { $this->aProperties['ends_at'] = Carbon::parse($this->strEndsAt, $this->strTimezone) ->setTimezone('UTC') ->toDateTimeString(); } }
php
protected function adjustDependentFields() { // Recurring-event fields if (array_key_exists('repeats', $this->aProperties) && !$this->repeats) { $this->frequency = null; $this->interval = self::INTERVAL_ONCE; $this->setWeekdays(); $this->ends_at = null; } // Datetimes & timezone if (!is_null($this->strStartsAt)) { $this->aProperties['starts_at'] = Carbon::parse($this->strStartsAt, $this->strTimezone) ->setTimezone('UTC') ->toDateTimeString(); } if (!is_null($this->strEndsAt)) { $this->aProperties['ends_at'] = Carbon::parse($this->strEndsAt, $this->strTimezone) ->setTimezone('UTC') ->toDateTimeString(); } }
[ "protected", "function", "adjustDependentFields", "(", ")", "{", "// Recurring-event fields", "if", "(", "array_key_exists", "(", "'repeats'", ",", "$", "this", "->", "aProperties", ")", "&&", "!", "$", "this", "->", "repeats", ")", "{", "$", "this", "->", "frequency", "=", "null", ";", "$", "this", "->", "interval", "=", "self", "::", "INTERVAL_ONCE", ";", "$", "this", "->", "setWeekdays", "(", ")", ";", "$", "this", "->", "ends_at", "=", "null", ";", "}", "// Datetimes & timezone", "if", "(", "!", "is_null", "(", "$", "this", "->", "strStartsAt", ")", ")", "{", "$", "this", "->", "aProperties", "[", "'starts_at'", "]", "=", "Carbon", "::", "parse", "(", "$", "this", "->", "strStartsAt", ",", "$", "this", "->", "strTimezone", ")", "->", "setTimezone", "(", "'UTC'", ")", "->", "toDateTimeString", "(", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "this", "->", "strEndsAt", ")", ")", "{", "$", "this", "->", "aProperties", "[", "'ends_at'", "]", "=", "Carbon", "::", "parse", "(", "$", "this", "->", "strEndsAt", ",", "$", "this", "->", "strTimezone", ")", "->", "setTimezone", "(", "'UTC'", ")", "->", "toDateTimeString", "(", ")", ";", "}", "}" ]
Adjust fields that are dependent upon other fields. - Reset all the recurring-event fields if not a repeating event. - Adjust datetimes for timezone offsets
[ "Adjust", "fields", "that", "are", "dependent", "upon", "other", "fields", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L249-L270
8,422
CampusUnion/Sked
src/SkeVent.php
SkeVent.getLeadTimeFactor
public static function getLeadTimeFactor(string $strFactor, int $iLeadTime) { // minutes if ($iLeadTime < 60 || $iLeadTime % 60 !== 0) { $iNum = $iLeadTime; $iUnit = 1; // hours } elseif ($iLeadTime % (24 * 60) !== 0) { $iNum = $iLeadTime / 60; $iUnit = 60; // days } else { $iNum = $iLeadTime / (24 * 60); $iUnit = 24 * 60; } return ${'i' . ucfirst(strtolower(str_replace('lead_time_', '', $strFactor)))}; }
php
public static function getLeadTimeFactor(string $strFactor, int $iLeadTime) { // minutes if ($iLeadTime < 60 || $iLeadTime % 60 !== 0) { $iNum = $iLeadTime; $iUnit = 1; // hours } elseif ($iLeadTime % (24 * 60) !== 0) { $iNum = $iLeadTime / 60; $iUnit = 60; // days } else { $iNum = $iLeadTime / (24 * 60); $iUnit = 24 * 60; } return ${'i' . ucfirst(strtolower(str_replace('lead_time_', '', $strFactor)))}; }
[ "public", "static", "function", "getLeadTimeFactor", "(", "string", "$", "strFactor", ",", "int", "$", "iLeadTime", ")", "{", "// minutes", "if", "(", "$", "iLeadTime", "<", "60", "||", "$", "iLeadTime", "%", "60", "!==", "0", ")", "{", "$", "iNum", "=", "$", "iLeadTime", ";", "$", "iUnit", "=", "1", ";", "// hours", "}", "elseif", "(", "$", "iLeadTime", "%", "(", "24", "*", "60", ")", "!==", "0", ")", "{", "$", "iNum", "=", "$", "iLeadTime", "/", "60", ";", "$", "iUnit", "=", "60", ";", "// days", "}", "else", "{", "$", "iNum", "=", "$", "iLeadTime", "/", "(", "24", "*", "60", ")", ";", "$", "iUnit", "=", "24", "*", "60", ";", "}", "return", "$", "{", "'i'", ".", "ucfirst", "(", "strtolower", "(", "str_replace", "(", "'lead_time_'", ",", "''", ",", "$", "strFactor", ")", ")", ")", "}", ";", "}" ]
Get the "num" or "unit" factor from the lead time. @param string $strFactor "lead_time_num" or "lead_time_unit" @return int
[ "Get", "the", "num", "or", "unit", "factor", "from", "the", "lead", "time", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L278-L295
8,423
CampusUnion/Sked
src/SkeVent.php
SkeVent.getMembers
public function getMembers() { if (empty($this->aMembers)) { $this->aMembers = []; if ($this->id) { foreach (Sked::getEventMembers($this->id) as $aEventMember) $this->aMembers[$aEventMember['member_id']] = $aEventMember; } } return $this->aMembers; }
php
public function getMembers() { if (empty($this->aMembers)) { $this->aMembers = []; if ($this->id) { foreach (Sked::getEventMembers($this->id) as $aEventMember) $this->aMembers[$aEventMember['member_id']] = $aEventMember; } } return $this->aMembers; }
[ "public", "function", "getMembers", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "aMembers", ")", ")", "{", "$", "this", "->", "aMembers", "=", "[", "]", ";", "if", "(", "$", "this", "->", "id", ")", "{", "foreach", "(", "Sked", "::", "getEventMembers", "(", "$", "this", "->", "id", ")", "as", "$", "aEventMember", ")", "$", "this", "->", "aMembers", "[", "$", "aEventMember", "[", "'member_id'", "]", "]", "=", "$", "aEventMember", ";", "}", "}", "return", "$", "this", "->", "aMembers", ";", "}" ]
Get associated sked_event_members. @return array
[ "Get", "associated", "sked_event_members", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L302-L312
8,424
CampusUnion/Sked
src/SkeVent.php
SkeVent.setMembers
public function setMembers(array $aEventMembers) { $this->aMembers = []; foreach ($aEventMembers as $iMemberId => $skeVentMember) $this->aMembers[$iMemberId] = $skeVentMember + ['member_id' => $iMemberId]; return $this; }
php
public function setMembers(array $aEventMembers) { $this->aMembers = []; foreach ($aEventMembers as $iMemberId => $skeVentMember) $this->aMembers[$iMemberId] = $skeVentMember + ['member_id' => $iMemberId]; return $this; }
[ "public", "function", "setMembers", "(", "array", "$", "aEventMembers", ")", "{", "$", "this", "->", "aMembers", "=", "[", "]", ";", "foreach", "(", "$", "aEventMembers", "as", "$", "iMemberId", "=>", "$", "skeVentMember", ")", "$", "this", "->", "aMembers", "[", "$", "iMemberId", "]", "=", "$", "skeVentMember", "+", "[", "'member_id'", "=>", "$", "iMemberId", "]", ";", "return", "$", "this", ";", "}" ]
Set associated sked_event_members. @param array $aEventMembers Array of SkeVentMember objects. @return $this
[ "Set", "associated", "sked_event_members", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L320-L328
8,425
CampusUnion/Sked
src/SkeVent.php
SkeVent.owner
public function owner() { $iReturn = 0; foreach ($this->getMembers() as $iId => $aMember) { if (1 == $aMember['owner']) { $iReturn = $iId; break; } } return $iReturn; }
php
public function owner() { $iReturn = 0; foreach ($this->getMembers() as $iId => $aMember) { if (1 == $aMember['owner']) { $iReturn = $iId; break; } } return $iReturn; }
[ "public", "function", "owner", "(", ")", "{", "$", "iReturn", "=", "0", ";", "foreach", "(", "$", "this", "->", "getMembers", "(", ")", "as", "$", "iId", "=>", "$", "aMember", ")", "{", "if", "(", "1", "==", "$", "aMember", "[", "'owner'", "]", ")", "{", "$", "iReturn", "=", "$", "iId", ";", "break", ";", "}", "}", "return", "$", "iReturn", ";", "}" ]
Get the event owner ID. @return int
[ "Get", "the", "event", "owner", "ID", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L335-L347
8,426
CampusUnion/Sked
src/SkeVent.php
SkeVent.getTags
public function getTags() { if (!is_array($this->aTags) && $this->id) { $this->aTags = []; foreach (Sked::getEventTags($this->id) as $aEventTag) $this->aTags[$aEventTag['tag_id']] = new SkeVentTag($aEventTag); } return $this->aTags; }
php
public function getTags() { if (!is_array($this->aTags) && $this->id) { $this->aTags = []; foreach (Sked::getEventTags($this->id) as $aEventTag) $this->aTags[$aEventTag['tag_id']] = new SkeVentTag($aEventTag); } return $this->aTags; }
[ "public", "function", "getTags", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "aTags", ")", "&&", "$", "this", "->", "id", ")", "{", "$", "this", "->", "aTags", "=", "[", "]", ";", "foreach", "(", "Sked", "::", "getEventTags", "(", "$", "this", "->", "id", ")", "as", "$", "aEventTag", ")", "$", "this", "->", "aTags", "[", "$", "aEventTag", "[", "'tag_id'", "]", "]", "=", "new", "SkeVentTag", "(", "$", "aEventTag", ")", ";", "}", "return", "$", "this", "->", "aTags", ";", "}" ]
Get associated sked_event_tags. @return array
[ "Get", "associated", "sked_event_tags", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L354-L362
8,427
CampusUnion/Sked
src/SkeVent.php
SkeVent.setTags
public function setTags(array $aEventTags) { $this->aTags = []; foreach ($aEventTags as $iTagId => $skeVentTag) { if (!$skeVentTag instanceof SkeVentTag) { $skeVentTag = new SkeVentTag([ 'tag_id' => $iTagId, 'value' => $skeVentTag, ]); } $this->aTags[$skeVentTag->tag_id] = $skeVentTag; } return $this; }
php
public function setTags(array $aEventTags) { $this->aTags = []; foreach ($aEventTags as $iTagId => $skeVentTag) { if (!$skeVentTag instanceof SkeVentTag) { $skeVentTag = new SkeVentTag([ 'tag_id' => $iTagId, 'value' => $skeVentTag, ]); } $this->aTags[$skeVentTag->tag_id] = $skeVentTag; } return $this; }
[ "public", "function", "setTags", "(", "array", "$", "aEventTags", ")", "{", "$", "this", "->", "aTags", "=", "[", "]", ";", "foreach", "(", "$", "aEventTags", "as", "$", "iTagId", "=>", "$", "skeVentTag", ")", "{", "if", "(", "!", "$", "skeVentTag", "instanceof", "SkeVentTag", ")", "{", "$", "skeVentTag", "=", "new", "SkeVentTag", "(", "[", "'tag_id'", "=>", "$", "iTagId", ",", "'value'", "=>", "$", "skeVentTag", ",", "]", ")", ";", "}", "$", "this", "->", "aTags", "[", "$", "skeVentTag", "->", "tag_id", "]", "=", "$", "skeVentTag", ";", "}", "return", "$", "this", ";", "}" ]
Set associated sked_event_tags. @param array $aEventTags Array of SkeVentTag objects. @return $this
[ "Set", "associated", "sked_event_tags", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L370-L385
8,428
CampusUnion/Sked
src/SkeVent.php
SkeVent.time
public function time(string $strFormat = 'g:ia', string $strTimezone = 'UTC') { return Carbon::parse($this->session_at ?? $this->starts_at) ->setTimezone($strTimezone) ->format($strFormat); }
php
public function time(string $strFormat = 'g:ia', string $strTimezone = 'UTC') { return Carbon::parse($this->session_at ?? $this->starts_at) ->setTimezone($strTimezone) ->format($strFormat); }
[ "public", "function", "time", "(", "string", "$", "strFormat", "=", "'g:ia'", ",", "string", "$", "strTimezone", "=", "'UTC'", ")", "{", "return", "Carbon", "::", "parse", "(", "$", "this", "->", "session_at", "??", "$", "this", "->", "starts_at", ")", "->", "setTimezone", "(", "$", "strTimezone", ")", "->", "format", "(", "$", "strFormat", ")", ";", "}" ]
Format the time using the given pattern. @param string $strFormat PHP date format. @param string $strTimezone PHP timezone name. @return string
[ "Format", "the", "time", "using", "the", "given", "pattern", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L394-L399
8,429
CampusUnion/Sked
src/SkeVent.php
SkeVent.toArray
public function toArray(bool $bIncludeExtras = true) { // Sanitize $this->adjustDependentFields(); $aReturn = array_filter($this->aProperties, function($mValue, $strKey) { return !empty($mValue) && '-' !== $mValue && ( in_array($strKey, ['created_at', 'updated_at']) || in_array($strKey, self::WEEKDAYS) || array_key_exists($strKey, Sked::form()->getFieldDefinitions()) ); }, ARRAY_FILTER_USE_BOTH); if (isset($aReturn['starts_at'])) $aReturn['starts_at'] = date('Y-m-d H:i:s', strtotime($aReturn['starts_at'])); if (isset($aReturn['ends_at'])) $aReturn['ends_at'] = date('Y-m-d H:i:s', strtotime($aReturn['ends_at'])); // Include tags? if ($bIncludeExtras) { $aReturn['tags'] = $this->getTags(); $aReturn['repeats'] = self::INTERVAL_ONCE !== $aReturn['interval'] ? '1' : null; } else { unset($aReturn['repeats']); } return $aReturn; }
php
public function toArray(bool $bIncludeExtras = true) { // Sanitize $this->adjustDependentFields(); $aReturn = array_filter($this->aProperties, function($mValue, $strKey) { return !empty($mValue) && '-' !== $mValue && ( in_array($strKey, ['created_at', 'updated_at']) || in_array($strKey, self::WEEKDAYS) || array_key_exists($strKey, Sked::form()->getFieldDefinitions()) ); }, ARRAY_FILTER_USE_BOTH); if (isset($aReturn['starts_at'])) $aReturn['starts_at'] = date('Y-m-d H:i:s', strtotime($aReturn['starts_at'])); if (isset($aReturn['ends_at'])) $aReturn['ends_at'] = date('Y-m-d H:i:s', strtotime($aReturn['ends_at'])); // Include tags? if ($bIncludeExtras) { $aReturn['tags'] = $this->getTags(); $aReturn['repeats'] = self::INTERVAL_ONCE !== $aReturn['interval'] ? '1' : null; } else { unset($aReturn['repeats']); } return $aReturn; }
[ "public", "function", "toArray", "(", "bool", "$", "bIncludeExtras", "=", "true", ")", "{", "// Sanitize", "$", "this", "->", "adjustDependentFields", "(", ")", ";", "$", "aReturn", "=", "array_filter", "(", "$", "this", "->", "aProperties", ",", "function", "(", "$", "mValue", ",", "$", "strKey", ")", "{", "return", "!", "empty", "(", "$", "mValue", ")", "&&", "'-'", "!==", "$", "mValue", "&&", "(", "in_array", "(", "$", "strKey", ",", "[", "'created_at'", ",", "'updated_at'", "]", ")", "||", "in_array", "(", "$", "strKey", ",", "self", "::", "WEEKDAYS", ")", "||", "array_key_exists", "(", "$", "strKey", ",", "Sked", "::", "form", "(", ")", "->", "getFieldDefinitions", "(", ")", ")", ")", ";", "}", ",", "ARRAY_FILTER_USE_BOTH", ")", ";", "if", "(", "isset", "(", "$", "aReturn", "[", "'starts_at'", "]", ")", ")", "$", "aReturn", "[", "'starts_at'", "]", "=", "date", "(", "'Y-m-d H:i:s'", ",", "strtotime", "(", "$", "aReturn", "[", "'starts_at'", "]", ")", ")", ";", "if", "(", "isset", "(", "$", "aReturn", "[", "'ends_at'", "]", ")", ")", "$", "aReturn", "[", "'ends_at'", "]", "=", "date", "(", "'Y-m-d H:i:s'", ",", "strtotime", "(", "$", "aReturn", "[", "'ends_at'", "]", ")", ")", ";", "// Include tags?", "if", "(", "$", "bIncludeExtras", ")", "{", "$", "aReturn", "[", "'tags'", "]", "=", "$", "this", "->", "getTags", "(", ")", ";", "$", "aReturn", "[", "'repeats'", "]", "=", "self", "::", "INTERVAL_ONCE", "!==", "$", "aReturn", "[", "'interval'", "]", "?", "'1'", ":", "null", ";", "}", "else", "{", "unset", "(", "$", "aReturn", "[", "'repeats'", "]", ")", ";", "}", "return", "$", "aReturn", ";", "}" ]
Convert to an array of database properties. @param bool $bIncludeExtras Should tags & "repeats" be included? @return array
[ "Convert", "to", "an", "array", "of", "database", "properties", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeVent.php#L407-L433
8,430
infotech-ru/yii-file-storage
src/Storage/AbstractStorage.php
AbstractStorage.get
public function get($path) { $localPath = $this->createUri($path); if (!file_exists($localPath)) { return null; } elseif (!is_readable($localPath)) { throw new Exception\OperationFailureException('File reading error.'); } else { return new FileDescriptor($localPath, filesize($localPath)); } }
php
public function get($path) { $localPath = $this->createUri($path); if (!file_exists($localPath)) { return null; } elseif (!is_readable($localPath)) { throw new Exception\OperationFailureException('File reading error.'); } else { return new FileDescriptor($localPath, filesize($localPath)); } }
[ "public", "function", "get", "(", "$", "path", ")", "{", "$", "localPath", "=", "$", "this", "->", "createUri", "(", "$", "path", ")", ";", "if", "(", "!", "file_exists", "(", "$", "localPath", ")", ")", "{", "return", "null", ";", "}", "elseif", "(", "!", "is_readable", "(", "$", "localPath", ")", ")", "{", "throw", "new", "Exception", "\\", "OperationFailureException", "(", "'File reading error.'", ")", ";", "}", "else", "{", "return", "new", "FileDescriptor", "(", "$", "localPath", ",", "filesize", "(", "$", "localPath", ")", ")", ";", "}", "}" ]
Fetch file from storage @param string $path @return \Infotech\FileStorage\File\FileDescriptor|null @throws \Infotech\FileStorage\Storage\Exception\OperationFailureException if storage failure
[ "Fetch", "file", "from", "storage" ]
812f9f0a147c1c9d637bc6ddc2af30647cf48772
https://github.com/infotech-ru/yii-file-storage/blob/812f9f0a147c1c9d637bc6ddc2af30647cf48772/src/Storage/AbstractStorage.php#L52-L62
8,431
infotech-ru/yii-file-storage
src/Storage/AbstractStorage.php
AbstractStorage.put
public function put($path, FileDescriptor $file) { $localPath = $this->createUri($path); if (false === copy($file->getUri(), $localPath)) { throw new Exception\OperationFailureException('Can\'t create file ' . $path . '.'); } }
php
public function put($path, FileDescriptor $file) { $localPath = $this->createUri($path); if (false === copy($file->getUri(), $localPath)) { throw new Exception\OperationFailureException('Can\'t create file ' . $path . '.'); } }
[ "public", "function", "put", "(", "$", "path", ",", "FileDescriptor", "$", "file", ")", "{", "$", "localPath", "=", "$", "this", "->", "createUri", "(", "$", "path", ")", ";", "if", "(", "false", "===", "copy", "(", "$", "file", "->", "getUri", "(", ")", ",", "$", "localPath", ")", ")", "{", "throw", "new", "Exception", "\\", "OperationFailureException", "(", "'Can\\'t create file '", ".", "$", "path", ".", "'.'", ")", ";", "}", "}" ]
Put file into storage @param string $path @param FileDescriptor $file @throws \Infotech\FileStorage\Storage\Exception\OperationFailureException if storage failure
[ "Put", "file", "into", "storage" ]
812f9f0a147c1c9d637bc6ddc2af30647cf48772
https://github.com/infotech-ru/yii-file-storage/blob/812f9f0a147c1c9d637bc6ddc2af30647cf48772/src/Storage/AbstractStorage.php#L71-L77
8,432
wplibs/session
src/Flash/Flash_Notifier.php
Flash_Notifier.update_last_message
protected function update_last_message( $overrides = [] ) { if ( $this->messages->isNotEmpty() ) { $this->messages->last()->update( $overrides ); } return $this; }
php
protected function update_last_message( $overrides = [] ) { if ( $this->messages->isNotEmpty() ) { $this->messages->last()->update( $overrides ); } return $this; }
[ "protected", "function", "update_last_message", "(", "$", "overrides", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "messages", "->", "isNotEmpty", "(", ")", ")", "{", "$", "this", "->", "messages", "->", "last", "(", ")", "->", "update", "(", "$", "overrides", ")", ";", "}", "return", "$", "this", ";", "}" ]
Modify the most recently added message. @param array $overrides The overrides attributes. @return $this
[ "Modify", "the", "most", "recently", "added", "message", "." ]
76d29e3f3b7d703e39c2497da214a42505fadd2b
https://github.com/wplibs/session/blob/76d29e3f3b7d703e39c2497da214a42505fadd2b/src/Flash/Flash_Notifier.php#L199-L205
8,433
0x20h/phloppy
src/Stream/CachingPool.php
CachingPool.updateNodes
private function updateNodes($key, StreamInterface $stream) { $this->nodeUrls = array_map(function (NodeInfo $element) { return $element->getServer(); }, (new Node($stream, $this->log))->hello()); $this->log->notice('caching connection info from HELLO', [ 'key' => $key, 'nodes' => $this->nodeUrls, 'ttl' => $this->getCacheTtl(), ]); $this->cache->set($key, $this->nodeUrls, $this->getCacheTtl()); }
php
private function updateNodes($key, StreamInterface $stream) { $this->nodeUrls = array_map(function (NodeInfo $element) { return $element->getServer(); }, (new Node($stream, $this->log))->hello()); $this->log->notice('caching connection info from HELLO', [ 'key' => $key, 'nodes' => $this->nodeUrls, 'ttl' => $this->getCacheTtl(), ]); $this->cache->set($key, $this->nodeUrls, $this->getCacheTtl()); }
[ "private", "function", "updateNodes", "(", "$", "key", ",", "StreamInterface", "$", "stream", ")", "{", "$", "this", "->", "nodeUrls", "=", "array_map", "(", "function", "(", "NodeInfo", "$", "element", ")", "{", "return", "$", "element", "->", "getServer", "(", ")", ";", "}", ",", "(", "new", "Node", "(", "$", "stream", ",", "$", "this", "->", "log", ")", ")", "->", "hello", "(", ")", ")", ";", "$", "this", "->", "log", "->", "notice", "(", "'caching connection info from HELLO'", ",", "[", "'key'", "=>", "$", "key", ",", "'nodes'", "=>", "$", "this", "->", "nodeUrls", ",", "'ttl'", "=>", "$", "this", "->", "getCacheTtl", "(", ")", ",", "]", ")", ";", "$", "this", "->", "cache", "->", "set", "(", "$", "key", ",", "$", "this", "->", "nodeUrls", ",", "$", "this", "->", "getCacheTtl", "(", ")", ")", ";", "}" ]
Update the node list using the HELLO command. @param string $key @param StreamInterface $stream
[ "Update", "the", "node", "list", "using", "the", "HELLO", "command", "." ]
d917f0578360395899bd583724046d36ac459535
https://github.com/0x20h/phloppy/blob/d917f0578360395899bd583724046d36ac459535/src/Stream/CachingPool.php#L113-L126
8,434
wambo-co/wambo-composer-installer
src/Wambo/ComposerInstaller/WamboInstaller.php
WamboInstaller.install
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) { $this->bootstrap(); // display info on "composer update" on command line echo 'add ' . $package->getName() . ' to wambo modules'; echo PHP_EOL; $wamboInstallerService = new WamboInstallerService($package); $className = $wamboInstallerService->getBootstrapClassName(); $name = $package->getName(); $version = $package->getVersion(); $module = new Module($name, $version, $className); $this->moduleRepository->add($module); parent::install($repo, $package); }
php
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) { $this->bootstrap(); // display info on "composer update" on command line echo 'add ' . $package->getName() . ' to wambo modules'; echo PHP_EOL; $wamboInstallerService = new WamboInstallerService($package); $className = $wamboInstallerService->getBootstrapClassName(); $name = $package->getName(); $version = $package->getVersion(); $module = new Module($name, $version, $className); $this->moduleRepository->add($module); parent::install($repo, $package); }
[ "public", "function", "install", "(", "InstalledRepositoryInterface", "$", "repo", ",", "PackageInterface", "$", "package", ")", "{", "$", "this", "->", "bootstrap", "(", ")", ";", "// display info on \"composer update\" on command line", "echo", "'add '", ".", "$", "package", "->", "getName", "(", ")", ".", "' to wambo modules'", ";", "echo", "PHP_EOL", ";", "$", "wamboInstallerService", "=", "new", "WamboInstallerService", "(", "$", "package", ")", ";", "$", "className", "=", "$", "wamboInstallerService", "->", "getBootstrapClassName", "(", ")", ";", "$", "name", "=", "$", "package", "->", "getName", "(", ")", ";", "$", "version", "=", "$", "package", "->", "getVersion", "(", ")", ";", "$", "module", "=", "new", "Module", "(", "$", "name", ",", "$", "version", ",", "$", "className", ")", ";", "$", "this", "->", "moduleRepository", "->", "add", "(", "$", "module", ")", ";", "parent", "::", "install", "(", "$", "repo", ",", "$", "package", ")", ";", "}" ]
Add a json node to the modules.json file. @param InstalledRepositoryInterface $repo repository in which to check @param PackageInterface $package package instance
[ "Add", "a", "json", "node", "to", "the", "modules", ".", "json", "file", "." ]
8560ee3b3244cc4528a7619a642dcc47b6364a3f
https://github.com/wambo-co/wambo-composer-installer/blob/8560ee3b3244cc4528a7619a642dcc47b6364a3f/src/Wambo/ComposerInstaller/WamboInstaller.php#L48-L66
8,435
Stratadox/HydrationMapping
src/Property/Relationship/CollectionMappingFailed.php
CollectionMappingFailed.forCollection
public static function forCollection( MapsProperty $mapping, Throwable $exception ): UnmappableInput { return new self( sprintf( 'Failed to map the %s collection of the `%s` property: %s', The::shortNameOfThe($mapping), $mapping->name(), $exception->getMessage() ), 0, $exception ); }
php
public static function forCollection( MapsProperty $mapping, Throwable $exception ): UnmappableInput { return new self( sprintf( 'Failed to map the %s collection of the `%s` property: %s', The::shortNameOfThe($mapping), $mapping->name(), $exception->getMessage() ), 0, $exception ); }
[ "public", "static", "function", "forCollection", "(", "MapsProperty", "$", "mapping", ",", "Throwable", "$", "exception", ")", ":", "UnmappableInput", "{", "return", "new", "self", "(", "sprintf", "(", "'Failed to map the %s collection of the `%s` property: %s'", ",", "The", "::", "shortNameOfThe", "(", "$", "mapping", ")", ",", "$", "mapping", "->", "name", "(", ")", ",", "$", "exception", "->", "getMessage", "(", ")", ")", ",", "0", ",", "$", "exception", ")", ";", "}" ]
Notifies the client code when a collection class could not be hydrated. @param MapsProperty $mapping The collection mapping that failed. @param Throwable $exception The exception that was encountered. @return UnmappableInput The collection mapping failure.
[ "Notifies", "the", "client", "code", "when", "a", "collection", "class", "could", "not", "be", "hydrated", "." ]
b145deaaf76ab8c8060f0cba1a8c6f73da375982
https://github.com/Stratadox/HydrationMapping/blob/b145deaaf76ab8c8060f0cba1a8c6f73da375982/src/Property/Relationship/CollectionMappingFailed.php#L54-L68
8,436
g3n1us/datatidy
src/DataTidy.php
DataTidy.response
protected function response($type = "json"){ $content = $this->simple_data($this->endpoint, $this->options->toArray()); $response = new Response; $response->setPublic(); if($this->options->get('allow_origin')) $response->header('Access-Control-Allow-Origin', $this->options->get('allow_origin')); $response->setContent($content)->send(); }
php
protected function response($type = "json"){ $content = $this->simple_data($this->endpoint, $this->options->toArray()); $response = new Response; $response->setPublic(); if($this->options->get('allow_origin')) $response->header('Access-Control-Allow-Origin', $this->options->get('allow_origin')); $response->setContent($content)->send(); }
[ "protected", "function", "response", "(", "$", "type", "=", "\"json\"", ")", "{", "$", "content", "=", "$", "this", "->", "simple_data", "(", "$", "this", "->", "endpoint", ",", "$", "this", "->", "options", "->", "toArray", "(", ")", ")", ";", "$", "response", "=", "new", "Response", ";", "$", "response", "->", "setPublic", "(", ")", ";", "if", "(", "$", "this", "->", "options", "->", "get", "(", "'allow_origin'", ")", ")", "$", "response", "->", "header", "(", "'Access-Control-Allow-Origin'", ",", "$", "this", "->", "options", "->", "get", "(", "'allow_origin'", ")", ")", ";", "$", "response", "->", "setContent", "(", "$", "content", ")", "->", "send", "(", ")", ";", "}" ]
Returns a full response using the result of a call to simple_data, by default an instance of Collection, otherwise, an array or JSON
[ "Returns", "a", "full", "response", "using", "the", "result", "of", "a", "call", "to", "simple_data", "by", "default", "an", "instance", "of", "Collection", "otherwise", "an", "array", "or", "JSON" ]
82a71e58f62cf236cb1f748465d7b5174669fbdd
https://github.com/g3n1us/datatidy/blob/82a71e58f62cf236cb1f748465d7b5174669fbdd/src/DataTidy.php#L36-L43
8,437
eycopia/excel
wrapper/Excel.php
Excel.newSheet
public function newSheet(){ $position = $this->engine->getSheetCount(); $this->engine->createSheet($position); $this->engine->setActiveSheetIndex($position); }
php
public function newSheet(){ $position = $this->engine->getSheetCount(); $this->engine->createSheet($position); $this->engine->setActiveSheetIndex($position); }
[ "public", "function", "newSheet", "(", ")", "{", "$", "position", "=", "$", "this", "->", "engine", "->", "getSheetCount", "(", ")", ";", "$", "this", "->", "engine", "->", "createSheet", "(", "$", "position", ")", ";", "$", "this", "->", "engine", "->", "setActiveSheetIndex", "(", "$", "position", ")", ";", "}" ]
Create a new Sheet @return void
[ "Create", "a", "new", "Sheet" ]
35c21825a3db164ed0a2b915f0d1cb5a9aeee9b2
https://github.com/eycopia/excel/blob/35c21825a3db164ed0a2b915f0d1cb5a9aeee9b2/wrapper/Excel.php#L61-L65
8,438
eycopia/excel
wrapper/Excel.php
Excel.setValue
public function setValue($cell, $row, $value, $border=false){ $this->engine->getActiveSheet()->setCellValueByColumnAndRow($cell, $row, $value); $this->x = $this->getColumnName($cell); $this->y = $row; if($border){ $this->engine->getActiveSheet()->getStyle("{$this->x}{$this->y}")->applyFromArray($this->style); } return $this; }
php
public function setValue($cell, $row, $value, $border=false){ $this->engine->getActiveSheet()->setCellValueByColumnAndRow($cell, $row, $value); $this->x = $this->getColumnName($cell); $this->y = $row; if($border){ $this->engine->getActiveSheet()->getStyle("{$this->x}{$this->y}")->applyFromArray($this->style); } return $this; }
[ "public", "function", "setValue", "(", "$", "cell", ",", "$", "row", ",", "$", "value", ",", "$", "border", "=", "false", ")", "{", "$", "this", "->", "engine", "->", "getActiveSheet", "(", ")", "->", "setCellValueByColumnAndRow", "(", "$", "cell", ",", "$", "row", ",", "$", "value", ")", ";", "$", "this", "->", "x", "=", "$", "this", "->", "getColumnName", "(", "$", "cell", ")", ";", "$", "this", "->", "y", "=", "$", "row", ";", "if", "(", "$", "border", ")", "{", "$", "this", "->", "engine", "->", "getActiveSheet", "(", ")", "->", "getStyle", "(", "\"{$this->x}{$this->y}\"", ")", "->", "applyFromArray", "(", "$", "this", "->", "style", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set value in a cell @param int $cell cell position (x start in 0) @param int $row row position (Y start en 1) @param string $value value to set @param boolean $border active/inactive cell borders @return Excel
[ "Set", "value", "in", "a", "cell" ]
35c21825a3db164ed0a2b915f0d1cb5a9aeee9b2
https://github.com/eycopia/excel/blob/35c21825a3db164ed0a2b915f0d1cb5a9aeee9b2/wrapper/Excel.php#L76-L84
8,439
eycopia/excel
wrapper/Excel.php
Excel.backgroundCell
public function backgroundCell($color, $cell=null, $row=null){ $color = str_replace("#", "", $color); if(!is_null($cell)){ $this->x = $this->getColumnName($cell); $this->y = $row; } $style = array('fill' => array( 'type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => "$color") ) ); $this->engine->getActiveSheet()->getStyle("{$this->x}{$this->y}")->applyFromArray($style); }
php
public function backgroundCell($color, $cell=null, $row=null){ $color = str_replace("#", "", $color); if(!is_null($cell)){ $this->x = $this->getColumnName($cell); $this->y = $row; } $style = array('fill' => array( 'type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => "$color") ) ); $this->engine->getActiveSheet()->getStyle("{$this->x}{$this->y}")->applyFromArray($style); }
[ "public", "function", "backgroundCell", "(", "$", "color", ",", "$", "cell", "=", "null", ",", "$", "row", "=", "null", ")", "{", "$", "color", "=", "str_replace", "(", "\"#\"", ",", "\"\"", ",", "$", "color", ")", ";", "if", "(", "!", "is_null", "(", "$", "cell", ")", ")", "{", "$", "this", "->", "x", "=", "$", "this", "->", "getColumnName", "(", "$", "cell", ")", ";", "$", "this", "->", "y", "=", "$", "row", ";", "}", "$", "style", "=", "array", "(", "'fill'", "=>", "array", "(", "'type'", "=>", "PHPExcel_Style_Fill", "::", "FILL_SOLID", ",", "'color'", "=>", "array", "(", "'rgb'", "=>", "\"$color\"", ")", ")", ")", ";", "$", "this", "->", "engine", "->", "getActiveSheet", "(", ")", "->", "getStyle", "(", "\"{$this->x}{$this->y}\"", ")", "->", "applyFromArray", "(", "$", "style", ")", ";", "}" ]
Set background color for a cell @param string $color color in hexadecimal @param int $cell cell position @param int $row row position @return void
[ "Set", "background", "color", "for", "a", "cell" ]
35c21825a3db164ed0a2b915f0d1cb5a9aeee9b2
https://github.com/eycopia/excel/blob/35c21825a3db164ed0a2b915f0d1cb5a9aeee9b2/wrapper/Excel.php#L94-L107
8,440
eycopia/excel
wrapper/Excel.php
Excel.bold
public function bold(){ $style = array( 'font' => array( 'bold' => true ) ); $this->engine->getActiveSheet()->getStyle("$this->x$this->y")->applyFromArray($style); return $this; }
php
public function bold(){ $style = array( 'font' => array( 'bold' => true ) ); $this->engine->getActiveSheet()->getStyle("$this->x$this->y")->applyFromArray($style); return $this; }
[ "public", "function", "bold", "(", ")", "{", "$", "style", "=", "array", "(", "'font'", "=>", "array", "(", "'bold'", "=>", "true", ")", ")", ";", "$", "this", "->", "engine", "->", "getActiveSheet", "(", ")", "->", "getStyle", "(", "\"$this->x$this->y\"", ")", "->", "applyFromArray", "(", "$", "style", ")", ";", "return", "$", "this", ";", "}" ]
Make the cell text in a cell Bold @return Excel
[ "Make", "the", "cell", "text", "in", "a", "cell", "Bold" ]
35c21825a3db164ed0a2b915f0d1cb5a9aeee9b2
https://github.com/eycopia/excel/blob/35c21825a3db164ed0a2b915f0d1cb5a9aeee9b2/wrapper/Excel.php#L113-L121
8,441
eycopia/excel
wrapper/Excel.php
Excel.color
public function color($color){ $style = array( 'font' => array( 'color' => array('rgb'=>$color) ) ); $this->engine->getActiveSheet()->getStyle("$this->x$this->y")->applyFromArray($style); return $this; }
php
public function color($color){ $style = array( 'font' => array( 'color' => array('rgb'=>$color) ) ); $this->engine->getActiveSheet()->getStyle("$this->x$this->y")->applyFromArray($style); return $this; }
[ "public", "function", "color", "(", "$", "color", ")", "{", "$", "style", "=", "array", "(", "'font'", "=>", "array", "(", "'color'", "=>", "array", "(", "'rgb'", "=>", "$", "color", ")", ")", ")", ";", "$", "this", "->", "engine", "->", "getActiveSheet", "(", ")", "->", "getStyle", "(", "\"$this->x$this->y\"", ")", "->", "applyFromArray", "(", "$", "style", ")", ";", "return", "$", "this", ";", "}" ]
Make set color on text @return Excel
[ "Make", "set", "color", "on", "text" ]
35c21825a3db164ed0a2b915f0d1cb5a9aeee9b2
https://github.com/eycopia/excel/blob/35c21825a3db164ed0a2b915f0d1cb5a9aeee9b2/wrapper/Excel.php#L127-L135
8,442
eycopia/excel
wrapper/Excel.php
Excel.findPosition
private function findPosition($index){ if ($index < $this->total){ $this->letter[] = $this->alphabet[$index]; } else { $mod = $index % $this->total; $div = (int) $index / $this->total; $this->letter[] = $this->alphabet[$mod]; $this->findPosition($div-1); } }
php
private function findPosition($index){ if ($index < $this->total){ $this->letter[] = $this->alphabet[$index]; } else { $mod = $index % $this->total; $div = (int) $index / $this->total; $this->letter[] = $this->alphabet[$mod]; $this->findPosition($div-1); } }
[ "private", "function", "findPosition", "(", "$", "index", ")", "{", "if", "(", "$", "index", "<", "$", "this", "->", "total", ")", "{", "$", "this", "->", "letter", "[", "]", "=", "$", "this", "->", "alphabet", "[", "$", "index", "]", ";", "}", "else", "{", "$", "mod", "=", "$", "index", "%", "$", "this", "->", "total", ";", "$", "div", "=", "(", "int", ")", "$", "index", "/", "$", "this", "->", "total", ";", "$", "this", "->", "letter", "[", "]", "=", "$", "this", "->", "alphabet", "[", "$", "mod", "]", ";", "$", "this", "->", "findPosition", "(", "$", "div", "-", "1", ")", ";", "}", "}" ]
Find a position for a letter @param $index
[ "Find", "a", "position", "for", "a", "letter" ]
35c21825a3db164ed0a2b915f0d1cb5a9aeee9b2
https://github.com/eycopia/excel/blob/35c21825a3db164ed0a2b915f0d1cb5a9aeee9b2/wrapper/Excel.php#L226-L236
8,443
arvici/framework
src/Arvici/Heart/Database/Driver/PDOConnection.php
PDOConnection.insert
public function insert($table, array $data) { // Prepare $columnPart = ""; $valuePart = ""; // Loop the data foreach ($data as $column => $value) { $columnPart .= "`$column`, "; $valuePart .= "?, "; } // Remove last commas $columnPart = substr($columnPart, 0, -2); $valuePart = substr($valuePart, 0, -2); $query = "INSERT INTO `$table` ($columnPart) VALUES ($valuePart)"; // Prepare and bind $statement = $this->prepare($query); $idx = 0; foreach ($data as $key => $value) { $statement->bindValue(($idx+1), $value, Database::typeOfValue($value)); $idx++; } // Execute and return the execute returning value. return $statement->execute(); }
php
public function insert($table, array $data) { // Prepare $columnPart = ""; $valuePart = ""; // Loop the data foreach ($data as $column => $value) { $columnPart .= "`$column`, "; $valuePart .= "?, "; } // Remove last commas $columnPart = substr($columnPart, 0, -2); $valuePart = substr($valuePart, 0, -2); $query = "INSERT INTO `$table` ($columnPart) VALUES ($valuePart)"; // Prepare and bind $statement = $this->prepare($query); $idx = 0; foreach ($data as $key => $value) { $statement->bindValue(($idx+1), $value, Database::typeOfValue($value)); $idx++; } // Execute and return the execute returning value. return $statement->execute(); }
[ "public", "function", "insert", "(", "$", "table", ",", "array", "$", "data", ")", "{", "// Prepare", "$", "columnPart", "=", "\"\"", ";", "$", "valuePart", "=", "\"\"", ";", "// Loop the data", "foreach", "(", "$", "data", "as", "$", "column", "=>", "$", "value", ")", "{", "$", "columnPart", ".=", "\"`$column`, \"", ";", "$", "valuePart", ".=", "\"?, \"", ";", "}", "// Remove last commas", "$", "columnPart", "=", "substr", "(", "$", "columnPart", ",", "0", ",", "-", "2", ")", ";", "$", "valuePart", "=", "substr", "(", "$", "valuePart", ",", "0", ",", "-", "2", ")", ";", "$", "query", "=", "\"INSERT INTO `$table` ($columnPart) VALUES ($valuePart)\"", ";", "// Prepare and bind", "$", "statement", "=", "$", "this", "->", "prepare", "(", "$", "query", ")", ";", "$", "idx", "=", "0", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "statement", "->", "bindValue", "(", "(", "$", "idx", "+", "1", ")", ",", "$", "value", ",", "Database", "::", "typeOfValue", "(", "$", "value", ")", ")", ";", "$", "idx", "++", ";", "}", "// Execute and return the execute returning value.", "return", "$", "statement", "->", "execute", "(", ")", ";", "}" ]
Insert data into the table. Will make a query for you and prepare the statement with the data. @param string $table @param array $data @throws DatabaseException @return bool Successful inserted?
[ "Insert", "data", "into", "the", "table", ".", "Will", "make", "a", "query", "for", "you", "and", "prepare", "the", "statement", "with", "the", "data", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Database/Driver/PDOConnection.php#L86-L116
8,444
arvici/framework
src/Arvici/Heart/Database/Driver/PDOConnection.php
PDOConnection.raw
public function raw($query, $return = false, $fetchMode = null, $fetchClass = null) { if (! $return) { return $this->exec($query); } $fetchMode = Database::normalizeFetchType($fetchMode); $statement = $this->query($query); if ($fetchMode === Database::FETCH_CLASS) { $statement->setFetchMode($fetchMode, $fetchClass); } else { $statement->setFetchMode($fetchMode); } return $statement->fetchAll(); }
php
public function raw($query, $return = false, $fetchMode = null, $fetchClass = null) { if (! $return) { return $this->exec($query); } $fetchMode = Database::normalizeFetchType($fetchMode); $statement = $this->query($query); if ($fetchMode === Database::FETCH_CLASS) { $statement->setFetchMode($fetchMode, $fetchClass); } else { $statement->setFetchMode($fetchMode); } return $statement->fetchAll(); }
[ "public", "function", "raw", "(", "$", "query", ",", "$", "return", "=", "false", ",", "$", "fetchMode", "=", "null", ",", "$", "fetchClass", "=", "null", ")", "{", "if", "(", "!", "$", "return", ")", "{", "return", "$", "this", "->", "exec", "(", "$", "query", ")", ";", "}", "$", "fetchMode", "=", "Database", "::", "normalizeFetchType", "(", "$", "fetchMode", ")", ";", "$", "statement", "=", "$", "this", "->", "query", "(", "$", "query", ")", ";", "if", "(", "$", "fetchMode", "===", "Database", "::", "FETCH_CLASS", ")", "{", "$", "statement", "->", "setFetchMode", "(", "$", "fetchMode", ",", "$", "fetchClass", ")", ";", "}", "else", "{", "$", "statement", "->", "setFetchMode", "(", "$", "fetchMode", ")", ";", "}", "return", "$", "statement", "->", "fetchAll", "(", ")", ";", "}" ]
Execute query. Warning! No escaping! @param string $query @param bool $return Return something back? (Fetch) @param int $fetchMode Fetch mode when returning something. @param string $fetchClass Class to fetch @return mixed @throws \Exception
[ "Execute", "query", ".", "Warning!", "No", "escaping!" ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Database/Driver/PDOConnection.php#L237-L254
8,445
arvici/framework
src/Arvici/Heart/Database/Driver/PDOConnection.php
PDOConnection.getDbalConnection
public function getDbalConnection() { $dbalDriver = ''; $driverCode = $this->getDriver()->getCode(); if ($driverCode === 'MySQL') $dbalDriver = 'pdo_mysql'; if ($dbalDriver == '') return null; $config = new Configuration(); $loggerChain = new LoggerChain(); if (\Arvici\Heart\Config\Configuration::get('app.env') == 'development') { $loggerChain->addLogger(new DoctrineLogBridge(\Logger::getInstance()->getMonologInstance())); $loggerChain->addLogger(DebugBarHelper::getInstance()->getDebugStack()); } $config->setSQLLogger($loggerChain); return DriverManager::getConnection([ 'driver' => $dbalDriver, 'pdo' => $this ], $config); }
php
public function getDbalConnection() { $dbalDriver = ''; $driverCode = $this->getDriver()->getCode(); if ($driverCode === 'MySQL') $dbalDriver = 'pdo_mysql'; if ($dbalDriver == '') return null; $config = new Configuration(); $loggerChain = new LoggerChain(); if (\Arvici\Heart\Config\Configuration::get('app.env') == 'development') { $loggerChain->addLogger(new DoctrineLogBridge(\Logger::getInstance()->getMonologInstance())); $loggerChain->addLogger(DebugBarHelper::getInstance()->getDebugStack()); } $config->setSQLLogger($loggerChain); return DriverManager::getConnection([ 'driver' => $dbalDriver, 'pdo' => $this ], $config); }
[ "public", "function", "getDbalConnection", "(", ")", "{", "$", "dbalDriver", "=", "''", ";", "$", "driverCode", "=", "$", "this", "->", "getDriver", "(", ")", "->", "getCode", "(", ")", ";", "if", "(", "$", "driverCode", "===", "'MySQL'", ")", "$", "dbalDriver", "=", "'pdo_mysql'", ";", "if", "(", "$", "dbalDriver", "==", "''", ")", "return", "null", ";", "$", "config", "=", "new", "Configuration", "(", ")", ";", "$", "loggerChain", "=", "new", "LoggerChain", "(", ")", ";", "if", "(", "\\", "Arvici", "\\", "Heart", "\\", "Config", "\\", "Configuration", "::", "get", "(", "'app.env'", ")", "==", "'development'", ")", "{", "$", "loggerChain", "->", "addLogger", "(", "new", "DoctrineLogBridge", "(", "\\", "Logger", "::", "getInstance", "(", ")", "->", "getMonologInstance", "(", ")", ")", ")", ";", "$", "loggerChain", "->", "addLogger", "(", "DebugBarHelper", "::", "getInstance", "(", ")", "->", "getDebugStack", "(", ")", ")", ";", "}", "$", "config", "->", "setSQLLogger", "(", "$", "loggerChain", ")", ";", "return", "DriverManager", "::", "getConnection", "(", "[", "'driver'", "=>", "$", "dbalDriver", ",", "'pdo'", "=>", "$", "this", "]", ",", "$", "config", ")", ";", "}" ]
Get DBAL Connection @return \Doctrine\DBAL\Connection
[ "Get", "DBAL", "Connection" ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Database/Driver/PDOConnection.php#L276-L297
8,446
tagadvance/Gilligan
src/tagadvance/gilligan/io/ResourceInputStream.php
ResourceInputStream.getContents
function getContents(int $maxLength = -1, int $offset = 0): string { $contents = stream_get_contents ( $this->handle, $maxLength, $offset ); if ($contents === false) { throw new IOException ( __METHOD__ . ' failed' ); } return $contents; }
php
function getContents(int $maxLength = -1, int $offset = 0): string { $contents = stream_get_contents ( $this->handle, $maxLength, $offset ); if ($contents === false) { throw new IOException ( __METHOD__ . ' failed' ); } return $contents; }
[ "function", "getContents", "(", "int", "$", "maxLength", "=", "-", "1", ",", "int", "$", "offset", "=", "0", ")", ":", "string", "{", "$", "contents", "=", "stream_get_contents", "(", "$", "this", "->", "handle", ",", "$", "maxLength", ",", "$", "offset", ")", ";", "if", "(", "$", "contents", "===", "false", ")", "{", "throw", "new", "IOException", "(", "__METHOD__", ".", "' failed'", ")", ";", "}", "return", "$", "contents", ";", "}" ]
Reads remainder of a stream into a string @param integer $maxLength The maximum bytes to read. Defaults to -1 (read all the remaining buffer). @param integer $offset Seek to the specified offset before reading. If this number is negative, no seeking will occur and reading will start from the current position. @return string @throws IOException @see http://php.net/manual/en/function.stream-get-contents.php
[ "Reads", "remainder", "of", "a", "stream", "into", "a", "string" ]
470c82b1ef16d0f839ba2245cd96cd414792483b
https://github.com/tagadvance/Gilligan/blob/470c82b1ef16d0f839ba2245cd96cd414792483b/src/tagadvance/gilligan/io/ResourceInputStream.php#L40-L46
8,447
vinala/kernel
src/Http/Redirect/Redirector.php
Redirector.getScheme
protected function getScheme($secured = null) { if (is_null($secured)) { if (is_null($this->cacheScheme)) { $this->cacheScheme = request('REQUEST_SCHEME', 'http', 'server').'://'; return $this->cacheScheme; } else { $this->cacheScheme; } } return $secured ? 'http://' : 'https://'; }
php
protected function getScheme($secured = null) { if (is_null($secured)) { if (is_null($this->cacheScheme)) { $this->cacheScheme = request('REQUEST_SCHEME', 'http', 'server').'://'; return $this->cacheScheme; } else { $this->cacheScheme; } } return $secured ? 'http://' : 'https://'; }
[ "protected", "function", "getScheme", "(", "$", "secured", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "secured", ")", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "cacheScheme", ")", ")", "{", "$", "this", "->", "cacheScheme", "=", "request", "(", "'REQUEST_SCHEME'", ",", "'http'", ",", "'server'", ")", ".", "'://'", ";", "return", "$", "this", "->", "cacheScheme", ";", "}", "else", "{", "$", "this", "->", "cacheScheme", ";", "}", "}", "return", "$", "secured", "?", "'http://'", ":", "'https://'", ";", "}" ]
Get the scheme. @param bool $secured @return string
[ "Get", "the", "scheme", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Redirect/Redirector.php#L97-L110
8,448
vinala/kernel
src/Http/Redirect/Redirector.php
Redirector.setParams
protected function setParams(array $args) { if (!empty($args)) { $request = '?'; } else { $request = ''; } foreach ($args as $key => $value) { if (is_numeric($key)) { if ($request != '?') { $request .= '&'; } $request .= $value; } elseif (is_string($key)) { if ($request != '?') { $request .= '&'; } $request .= $key.'='.$value; } } return $request; }
php
protected function setParams(array $args) { if (!empty($args)) { $request = '?'; } else { $request = ''; } foreach ($args as $key => $value) { if (is_numeric($key)) { if ($request != '?') { $request .= '&'; } $request .= $value; } elseif (is_string($key)) { if ($request != '?') { $request .= '&'; } $request .= $key.'='.$value; } } return $request; }
[ "protected", "function", "setParams", "(", "array", "$", "args", ")", "{", "if", "(", "!", "empty", "(", "$", "args", ")", ")", "{", "$", "request", "=", "'?'", ";", "}", "else", "{", "$", "request", "=", "''", ";", "}", "foreach", "(", "$", "args", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_numeric", "(", "$", "key", ")", ")", "{", "if", "(", "$", "request", "!=", "'?'", ")", "{", "$", "request", ".=", "'&'", ";", "}", "$", "request", ".=", "$", "value", ";", "}", "elseif", "(", "is_string", "(", "$", "key", ")", ")", "{", "if", "(", "$", "request", "!=", "'?'", ")", "{", "$", "request", ".=", "'&'", ";", "}", "$", "request", ".=", "$", "key", ".", "'='", ".", "$", "value", ";", "}", "}", "return", "$", "request", ";", "}" ]
To set get parameters. @param array $args @return string
[ "To", "set", "get", "parameters", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Redirect/Redirector.php#L119-L142
8,449
vinala/kernel
src/Http/Redirect/Redirector.php
Redirector.route
public function route($route, $secure = null) { $path = Url::root(); if ($route == '/') { $route = $path; } else { $route = $path.$route; } return self::locate($route, $secure); }
php
public function route($route, $secure = null) { $path = Url::root(); if ($route == '/') { $route = $path; } else { $route = $path.$route; } return self::locate($route, $secure); }
[ "public", "function", "route", "(", "$", "route", ",", "$", "secure", "=", "null", ")", "{", "$", "path", "=", "Url", "::", "root", "(", ")", ";", "if", "(", "$", "route", "==", "'/'", ")", "{", "$", "route", "=", "$", "path", ";", "}", "else", "{", "$", "route", "=", "$", "path", ".", "$", "route", ";", "}", "return", "self", "::", "locate", "(", "$", "route", ",", "$", "secure", ")", ";", "}" ]
Redirect to route. @param string $route @param bool $secure @return mixed
[ "Redirect", "to", "route", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Redirect/Redirector.php#L178-L189
8,450
Dhii/di-abstract
src/GetServiceCapableCachingTrait.php
GetServiceCapableCachingTrait._getService
protected function _getService($key) { $cache = $this->_getServiceCache(); $notFoundException = null; try { return $cache->get($key, function ($key) use (&$notFoundException) { try { $definition = $this->_get($key); } catch (NotFoundExceptionInterface $e) { $notFoundException = $e; throw $e; } return $this->_resolveDefinition($definition); }); } catch (RootException $e) { if ($notFoundException instanceof NotFoundExceptionInterface) { throw $notFoundException; } throw $this->_throwContainerException($this->__('Could not retrieve service'), null, $e, true); } }
php
protected function _getService($key) { $cache = $this->_getServiceCache(); $notFoundException = null; try { return $cache->get($key, function ($key) use (&$notFoundException) { try { $definition = $this->_get($key); } catch (NotFoundExceptionInterface $e) { $notFoundException = $e; throw $e; } return $this->_resolveDefinition($definition); }); } catch (RootException $e) { if ($notFoundException instanceof NotFoundExceptionInterface) { throw $notFoundException; } throw $this->_throwContainerException($this->__('Could not retrieve service'), null, $e, true); } }
[ "protected", "function", "_getService", "(", "$", "key", ")", "{", "$", "cache", "=", "$", "this", "->", "_getServiceCache", "(", ")", ";", "$", "notFoundException", "=", "null", ";", "try", "{", "return", "$", "cache", "->", "get", "(", "$", "key", ",", "function", "(", "$", "key", ")", "use", "(", "&", "$", "notFoundException", ")", "{", "try", "{", "$", "definition", "=", "$", "this", "->", "_get", "(", "$", "key", ")", ";", "}", "catch", "(", "NotFoundExceptionInterface", "$", "e", ")", "{", "$", "notFoundException", "=", "$", "e", ";", "throw", "$", "e", ";", "}", "return", "$", "this", "->", "_resolveDefinition", "(", "$", "definition", ")", ";", "}", ")", ";", "}", "catch", "(", "RootException", "$", "e", ")", "{", "if", "(", "$", "notFoundException", "instanceof", "NotFoundExceptionInterface", ")", "{", "throw", "$", "notFoundException", ";", "}", "throw", "$", "this", "->", "_throwContainerException", "(", "$", "this", "->", "__", "(", "'Could not retrieve service'", ")", ",", "null", ",", "$", "e", ",", "true", ")", ";", "}", "}" ]
Retrieves a service by key. @since [*next-version*] @param string|int|float|bool|Stringable $key The key, for which to get the service. @throw NotFoundExceptionInterface If no service or definition found for key. @throw ContainerExceptionInterface If service or service definition could not be retrieved. @return mixed The corresponding service.
[ "Retrieves", "a", "service", "by", "key", "." ]
badfa20def27e5c6883f1c1078c98603b7bee319
https://github.com/Dhii/di-abstract/blob/badfa20def27e5c6883f1c1078c98603b7bee319/src/GetServiceCapableCachingTrait.php#L32-L55
8,451
johanderuijter/mailer
src/Part/MessageResolver.php
MessageResolver.resolveBody
private function resolveBody(Message $part) { $body = $part->getBody(); foreach ($part->getParameters() as $search => $replace) { $body = str_replace($search, $replace, $body); } return $body; }
php
private function resolveBody(Message $part) { $body = $part->getBody(); foreach ($part->getParameters() as $search => $replace) { $body = str_replace($search, $replace, $body); } return $body; }
[ "private", "function", "resolveBody", "(", "Message", "$", "part", ")", "{", "$", "body", "=", "$", "part", "->", "getBody", "(", ")", ";", "foreach", "(", "$", "part", "->", "getParameters", "(", ")", "as", "$", "search", "=>", "$", "replace", ")", "{", "$", "body", "=", "str_replace", "(", "$", "search", ",", "$", "replace", ",", "$", "body", ")", ";", "}", "return", "$", "body", ";", "}" ]
Resolve the body of the message. @return string
[ "Resolve", "the", "body", "of", "the", "message", "." ]
5a0cbb7f8be91bb1fc7a4816964dddaff10ac25c
https://github.com/johanderuijter/mailer/blob/5a0cbb7f8be91bb1fc7a4816964dddaff10ac25c/src/Part/MessageResolver.php#L25-L33
8,452
samurai-fw/samurai
src/Samurai/Component/Helper/FormHelper.php
FormHelper.open
public function open($url, array $attributes = []) { $tag = new Tag('form', $attributes); $tag->action = $url; $tag->method = 'POST'; return $tag; }
php
public function open($url, array $attributes = []) { $tag = new Tag('form', $attributes); $tag->action = $url; $tag->method = 'POST'; return $tag; }
[ "public", "function", "open", "(", "$", "url", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "tag", "=", "new", "Tag", "(", "'form'", ",", "$", "attributes", ")", ";", "$", "tag", "->", "action", "=", "$", "url", ";", "$", "tag", "->", "method", "=", "'POST'", ";", "return", "$", "tag", ";", "}" ]
open form tag. @param string $url @param array $attributes @return Tag
[ "open", "form", "tag", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Helper/FormHelper.php#L61-L67
8,453
samurai-fw/samurai
src/Samurai/Component/Helper/FormHelper.php
FormHelper.model
public function model(Entity $model, $url, array $attributes = []) { $this->model = $model; $tag = $this->open($url, $attributes); return $tag; }
php
public function model(Entity $model, $url, array $attributes = []) { $this->model = $model; $tag = $this->open($url, $attributes); return $tag; }
[ "public", "function", "model", "(", "Entity", "$", "model", ",", "$", "url", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "this", "->", "model", "=", "$", "model", ";", "$", "tag", "=", "$", "this", "->", "open", "(", "$", "url", ",", "$", "attributes", ")", ";", "return", "$", "tag", ";", "}" ]
open form tag using model @param Entity $model @param string $url @param array $attributes @return Tag
[ "open", "form", "tag", "using", "model" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Helper/FormHelper.php#L77-L83
8,454
samurai-fw/samurai
src/Samurai/Component/Helper/FormHelper.php
FormHelper.close
public function close() { $tag = new Tag('form'); $tag->closeMode = Tag::CLOSE_ONLY; $this->model = null; return $tag; }
php
public function close() { $tag = new Tag('form'); $tag->closeMode = Tag::CLOSE_ONLY; $this->model = null; return $tag; }
[ "public", "function", "close", "(", ")", "{", "$", "tag", "=", "new", "Tag", "(", "'form'", ")", ";", "$", "tag", "->", "closeMode", "=", "Tag", "::", "CLOSE_ONLY", ";", "$", "this", "->", "model", "=", "null", ";", "return", "$", "tag", ";", "}" ]
close form tag. @return Tag
[ "close", "form", "tag", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Helper/FormHelper.php#L90-L98
8,455
samurai-fw/samurai
src/Samurai/Component/Helper/FormHelper.php
FormHelper.text
public function text($name, $value = null, array $attributes = []) { $value = $this->getDefaultValue($name, $value); return $this->input('text', $name, $value, $attributes); }
php
public function text($name, $value = null, array $attributes = []) { $value = $this->getDefaultValue($name, $value); return $this->input('text', $name, $value, $attributes); }
[ "public", "function", "text", "(", "$", "name", ",", "$", "value", "=", "null", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "value", "=", "$", "this", "->", "getDefaultValue", "(", "$", "name", ",", "$", "value", ")", ";", "return", "$", "this", "->", "input", "(", "'text'", ",", "$", "name", ",", "$", "value", ",", "$", "attributes", ")", ";", "}" ]
text input tag @param string $name @param string $value @param array $attributes @return Tag
[ "text", "input", "tag" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Helper/FormHelper.php#L141-L145
8,456
samurai-fw/samurai
src/Samurai/Component/Helper/FormHelper.php
FormHelper.date
public function date($name, $value = null, array $attributes = []) { $value = $this->getDefaultValue($name, $value); return $this->input('date', $name, $value, $attributes); }
php
public function date($name, $value = null, array $attributes = []) { $value = $this->getDefaultValue($name, $value); return $this->input('date', $name, $value, $attributes); }
[ "public", "function", "date", "(", "$", "name", ",", "$", "value", "=", "null", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "value", "=", "$", "this", "->", "getDefaultValue", "(", "$", "name", ",", "$", "value", ")", ";", "return", "$", "this", "->", "input", "(", "'date'", ",", "$", "name", ",", "$", "value", ",", "$", "attributes", ")", ";", "}" ]
date input tag @param string $name @param string $value @param array $attributes @return Tag
[ "date", "input", "tag" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Helper/FormHelper.php#L155-L159
8,457
samurai-fw/samurai
src/Samurai/Component/Helper/FormHelper.php
FormHelper.getDefaultValue
protected function getDefaultValue($name, $value = null) { if ($value !== null) return $value; if ($this->model && $this->model->has($name)) return $this->model->get($name); return $value; }
php
protected function getDefaultValue($name, $value = null) { if ($value !== null) return $value; if ($this->model && $this->model->has($name)) return $this->model->get($name); return $value; }
[ "protected", "function", "getDefaultValue", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "if", "(", "$", "value", "!==", "null", ")", "return", "$", "value", ";", "if", "(", "$", "this", "->", "model", "&&", "$", "this", "->", "model", "->", "has", "(", "$", "name", ")", ")", "return", "$", "this", "->", "model", "->", "get", "(", "$", "name", ")", ";", "return", "$", "value", ";", "}" ]
get default value 1. from argument 2. from request 3. from model @param string $name @param string $value @return mixed
[ "get", "default", "value" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Helper/FormHelper.php#L301-L310
8,458
imsamurai/cakephp-task-plugin
Lib/Task/TaskProcess.php
TaskProcess._terminate
protected function _terminate($timeout = 10, $signal = /* SIGTERM */ 15) { foreach ($this->_getPidRecursive($this->getPid()) as $pid) { posix_kill($pid, $signal); } parent::stop($timeout, $signal); }
php
protected function _terminate($timeout = 10, $signal = /* SIGTERM */ 15) { foreach ($this->_getPidRecursive($this->getPid()) as $pid) { posix_kill($pid, $signal); } parent::stop($timeout, $signal); }
[ "protected", "function", "_terminate", "(", "$", "timeout", "=", "10", ",", "$", "signal", "=", "/* SIGTERM */", "15", ")", "{", "foreach", "(", "$", "this", "->", "_getPidRecursive", "(", "$", "this", "->", "getPid", "(", ")", ")", "as", "$", "pid", ")", "{", "posix_kill", "(", "$", "pid", ",", "$", "signal", ")", ";", "}", "parent", "::", "stop", "(", "$", "timeout", ",", "$", "signal", ")", ";", "}" ]
Terminate current process @param int $timeout @param int $signal
[ "Terminate", "current", "process" ]
9d7bd9fa908abf0ae5c24f27aa829a39ac034961
https://github.com/imsamurai/cakephp-task-plugin/blob/9d7bd9fa908abf0ae5c24f27aa829a39ac034961/Lib/Task/TaskProcess.php#L38-L43
8,459
imsamurai/cakephp-task-plugin
Lib/Task/TaskProcess.php
TaskProcess._getPidRecursive
protected function _getPidRecursive($ppid) { if (!$ppid) { return array(); } $allPids = $pids = array_filter(preg_split('/\s+/', `ps -o pid --no-heading --ppid $ppid`)); foreach ($pids as $pid) { $allPids = array_merge($allPids, $this->_getPidRecursive($pid)); } return $allPids; }
php
protected function _getPidRecursive($ppid) { if (!$ppid) { return array(); } $allPids = $pids = array_filter(preg_split('/\s+/', `ps -o pid --no-heading --ppid $ppid`)); foreach ($pids as $pid) { $allPids = array_merge($allPids, $this->_getPidRecursive($pid)); } return $allPids; }
[ "protected", "function", "_getPidRecursive", "(", "$", "ppid", ")", "{", "if", "(", "!", "$", "ppid", ")", "{", "return", "array", "(", ")", ";", "}", "$", "allPids", "=", "$", "pids", "=", "array_filter", "(", "preg_split", "(", "'/\\s+/'", ",", "`ps -o pid --no-heading --ppid $ppid`", ")", ")", ";", "foreach", "(", "$", "pids", "as", "$", "pid", ")", "{", "$", "allPids", "=", "array_merge", "(", "$", "allPids", ",", "$", "this", "->", "_getPidRecursive", "(", "$", "pid", ")", ")", ";", "}", "return", "$", "allPids", ";", "}" ]
Collect all childrens pids recursively @param int $ppid @return array
[ "Collect", "all", "childrens", "pids", "recursively" ]
9d7bd9fa908abf0ae5c24f27aa829a39ac034961
https://github.com/imsamurai/cakephp-task-plugin/blob/9d7bd9fa908abf0ae5c24f27aa829a39ac034961/Lib/Task/TaskProcess.php#L51-L61
8,460
dekuan/deuclientpro
src/UClientPro.php
UClientPro.makeLogin
public function makeLogin( $vData, $bKeepAlive = false, & $sCkString = '' ) { if ( UCProLib::isValidXTArray( $vData ) ) { return $this->m_cUCProMain->makeLoginByXTArray( $vData, $bKeepAlive, $sCkString ); } else if ( CLib::IsExistingString( $vData ) ) { return $this->m_cUCProMain->makeLoginByCookieString( $vData, $bKeepAlive, true ); } else { return UCProError::UCLIENTPRO_MAKELOGIN_FAILURE; } }
php
public function makeLogin( $vData, $bKeepAlive = false, & $sCkString = '' ) { if ( UCProLib::isValidXTArray( $vData ) ) { return $this->m_cUCProMain->makeLoginByXTArray( $vData, $bKeepAlive, $sCkString ); } else if ( CLib::IsExistingString( $vData ) ) { return $this->m_cUCProMain->makeLoginByCookieString( $vData, $bKeepAlive, true ); } else { return UCProError::UCLIENTPRO_MAKELOGIN_FAILURE; } }
[ "public", "function", "makeLogin", "(", "$", "vData", ",", "$", "bKeepAlive", "=", "false", ",", "&", "$", "sCkString", "=", "''", ")", "{", "if", "(", "UCProLib", "::", "isValidXTArray", "(", "$", "vData", ")", ")", "{", "return", "$", "this", "->", "m_cUCProMain", "->", "makeLoginByXTArray", "(", "$", "vData", ",", "$", "bKeepAlive", ",", "$", "sCkString", ")", ";", "}", "else", "if", "(", "CLib", "::", "IsExistingString", "(", "$", "vData", ")", ")", "{", "return", "$", "this", "->", "m_cUCProMain", "->", "makeLoginByCookieString", "(", "$", "vData", ",", "$", "bKeepAlive", ",", "true", ")", ";", "}", "else", "{", "return", "UCProError", "::", "UCLIENTPRO_MAKELOGIN_FAILURE", ";", "}", "}" ]
make user login @param $vData @param bool $bKeepAlive @param string $sCkString @return int
[ "make", "user", "login" ]
56f39ad0efc023d7e069f34df1f15e4324fca84e
https://github.com/dekuan/deuclientpro/blob/56f39ad0efc023d7e069f34df1f15e4324fca84e/src/UClientPro.php#L84-L98
8,461
dekuan/deuclientpro
src/UClientPro.php
UClientPro.isCookieAlive
public function isCookieAlive() { // ... $bRet = false; if ( $this->isKeepAlive() ) { // // return false if user set to keep alive // $bRet = true; } else { // ... $nLoginTime = $this->m_cUCProMain->getXTInstance()->getTValue( UCProConst::CKT_LOGIN_TM ); if ( is_numeric( $nLoginTime ) ) { // // escaped time in seconds after user logged in // the default timeout is 1 day. // $fTerm = floatval( time() - floatval( $nLoginTime ) ); $bRet = ( $fTerm <= $this->m_cUCProMain->getConfig_nCookieTimeout() ); } else { // // login time is invalid // So, we marked this cookie as timeout // $bRet = false; } } return $bRet; }
php
public function isCookieAlive() { // ... $bRet = false; if ( $this->isKeepAlive() ) { // // return false if user set to keep alive // $bRet = true; } else { // ... $nLoginTime = $this->m_cUCProMain->getXTInstance()->getTValue( UCProConst::CKT_LOGIN_TM ); if ( is_numeric( $nLoginTime ) ) { // // escaped time in seconds after user logged in // the default timeout is 1 day. // $fTerm = floatval( time() - floatval( $nLoginTime ) ); $bRet = ( $fTerm <= $this->m_cUCProMain->getConfig_nCookieTimeout() ); } else { // // login time is invalid // So, we marked this cookie as timeout // $bRet = false; } } return $bRet; }
[ "public", "function", "isCookieAlive", "(", ")", "{", "//\t...", "$", "bRet", "=", "false", ";", "if", "(", "$", "this", "->", "isKeepAlive", "(", ")", ")", "{", "//", "//\treturn false if user set to keep alive", "//", "$", "bRet", "=", "true", ";", "}", "else", "{", "//\t...", "$", "nLoginTime", "=", "$", "this", "->", "m_cUCProMain", "->", "getXTInstance", "(", ")", "->", "getTValue", "(", "UCProConst", "::", "CKT_LOGIN_TM", ")", ";", "if", "(", "is_numeric", "(", "$", "nLoginTime", ")", ")", "{", "//", "//\tescaped time in seconds after user logged in", "// the default timeout is 1 day.", "//", "$", "fTerm", "=", "floatval", "(", "time", "(", ")", "-", "floatval", "(", "$", "nLoginTime", ")", ")", ";", "$", "bRet", "=", "(", "$", "fTerm", "<=", "$", "this", "->", "m_cUCProMain", "->", "getConfig_nCookieTimeout", "(", ")", ")", ";", "}", "else", "{", "//", "// login time is invalid", "// So, we marked this cookie as timeout", "//", "$", "bRet", "=", "false", ";", "}", "}", "return", "$", "bRet", ";", "}" ]
check if cookie alive @return bool
[ "check", "if", "cookie", "alive" ]
56f39ad0efc023d7e069f34df1f15e4324fca84e
https://github.com/dekuan/deuclientpro/blob/56f39ad0efc023d7e069f34df1f15e4324fca84e/src/UClientPro.php#L188-L224
8,462
dekuan/deuclientpro
src/UClientPro.php
UClientPro.isKeepAlive
public function isKeepAlive() { $nKeepAlive = intval( $this->m_cUCProMain->getXTInstance()->getTValue( UCProConst::CKT_KP_ALIVE ) ); return ( 1 === $nKeepAlive ); }
php
public function isKeepAlive() { $nKeepAlive = intval( $this->m_cUCProMain->getXTInstance()->getTValue( UCProConst::CKT_KP_ALIVE ) ); return ( 1 === $nKeepAlive ); }
[ "public", "function", "isKeepAlive", "(", ")", "{", "$", "nKeepAlive", "=", "intval", "(", "$", "this", "->", "m_cUCProMain", "->", "getXTInstance", "(", ")", "->", "getTValue", "(", "UCProConst", "::", "CKT_KP_ALIVE", ")", ")", ";", "return", "(", "1", "===", "$", "nKeepAlive", ")", ";", "}" ]
if user set flag to keep the session alive @return bool
[ "if", "user", "set", "flag", "to", "keep", "the", "session", "alive" ]
56f39ad0efc023d7e069f34df1f15e4324fca84e
https://github.com/dekuan/deuclientpro/blob/56f39ad0efc023d7e069f34df1f15e4324fca84e/src/UClientPro.php#L231-L235
8,463
gdmgent/artestead
src/MakeCommand.php
MakeCommand.configureAliases
protected function configureAliases() { $file = "{$this->basePath}/aliases.sh"; if (file_exists($file)) { $fileContent = file_get_contents($file); $fileContent = str_replace( 'alias p=\'cd ~/Code/artestead\'', 'alias p=\'cd ~/Code/'.$this->defaultName.'\'', $fileContent ); file_put_contents($file, $fileContent); } }
php
protected function configureAliases() { $file = "{$this->basePath}/aliases.sh"; if (file_exists($file)) { $fileContent = file_get_contents($file); $fileContent = str_replace( 'alias p=\'cd ~/Code/artestead\'', 'alias p=\'cd ~/Code/'.$this->defaultName.'\'', $fileContent ); file_put_contents($file, $fileContent); } }
[ "protected", "function", "configureAliases", "(", ")", "{", "$", "file", "=", "\"{$this->basePath}/aliases.sh\"", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "$", "fileContent", "=", "file_get_contents", "(", "$", "file", ")", ";", "$", "fileContent", "=", "str_replace", "(", "'alias p=\\'cd ~/Code/artestead\\''", ",", "'alias p=\\'cd ~/Code/'", ".", "$", "this", "->", "defaultName", ".", "'\\''", ",", "$", "fileContent", ")", ";", "file_put_contents", "(", "$", "file", ",", "$", "fileContent", ")", ";", "}", "}" ]
Updates the aliases file with a shortcut to the project folder.
[ "Updates", "the", "aliases", "file", "with", "a", "shortcut", "to", "the", "project", "folder", "." ]
1795d8f59c9132fe240ba4cab0bcf34762e52535
https://github.com/gdmgent/artestead/blob/1795d8f59c9132fe240ba4cab0bcf34762e52535/src/MakeCommand.php#L276-L288
8,464
novuso/common
src/Application/Messaging/Event/Subscriber/EventLogger.php
EventLogger.logEvent
public function logEvent(EventMessage $message): void { $name = $message->payloadType()->toString(); $this->logger->info( sprintf('Event dispatched {%s}', $name), ['message' => $message->toString()] ); }
php
public function logEvent(EventMessage $message): void { $name = $message->payloadType()->toString(); $this->logger->info( sprintf('Event dispatched {%s}', $name), ['message' => $message->toString()] ); }
[ "public", "function", "logEvent", "(", "EventMessage", "$", "message", ")", ":", "void", "{", "$", "name", "=", "$", "message", "->", "payloadType", "(", ")", "->", "toString", "(", ")", ";", "$", "this", "->", "logger", "->", "info", "(", "sprintf", "(", "'Event dispatched {%s}'", ",", "$", "name", ")", ",", "[", "'message'", "=>", "$", "message", "->", "toString", "(", ")", "]", ")", ";", "}" ]
Logs the event message @param EventMessage $message The event message @return void
[ "Logs", "the", "event", "message" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Messaging/Event/Subscriber/EventLogger.php#L51-L59
8,465
mszewcz/php-light-framework
src/Config/Writer/Xml.php
Xml.addChildNode
private function addChildNode(string $name, array $config, \XMLWriter $writer): void { $writer->startElement($name); foreach ($config as $nodeName => $nodeData) { $nodeName = \is_numeric($nodeName) ? 'num__'.$nodeName : $nodeName; if (\is_array($nodeData)) { $this->addChildNode($nodeName, $nodeData, $writer); } elseif (\is_bool($nodeData)) { $writer->writeElement($nodeName, $nodeData === true ? 'true' : 'false'); } else { $writer->writeElement($nodeName, (string)$nodeData); } } $writer->endElement(); }
php
private function addChildNode(string $name, array $config, \XMLWriter $writer): void { $writer->startElement($name); foreach ($config as $nodeName => $nodeData) { $nodeName = \is_numeric($nodeName) ? 'num__'.$nodeName : $nodeName; if (\is_array($nodeData)) { $this->addChildNode($nodeName, $nodeData, $writer); } elseif (\is_bool($nodeData)) { $writer->writeElement($nodeName, $nodeData === true ? 'true' : 'false'); } else { $writer->writeElement($nodeName, (string)$nodeData); } } $writer->endElement(); }
[ "private", "function", "addChildNode", "(", "string", "$", "name", ",", "array", "$", "config", ",", "\\", "XMLWriter", "$", "writer", ")", ":", "void", "{", "$", "writer", "->", "startElement", "(", "$", "name", ")", ";", "foreach", "(", "$", "config", "as", "$", "nodeName", "=>", "$", "nodeData", ")", "{", "$", "nodeName", "=", "\\", "is_numeric", "(", "$", "nodeName", ")", "?", "'num__'", ".", "$", "nodeName", ":", "$", "nodeName", ";", "if", "(", "\\", "is_array", "(", "$", "nodeData", ")", ")", "{", "$", "this", "->", "addChildNode", "(", "$", "nodeName", ",", "$", "nodeData", ",", "$", "writer", ")", ";", "}", "elseif", "(", "\\", "is_bool", "(", "$", "nodeData", ")", ")", "{", "$", "writer", "->", "writeElement", "(", "$", "nodeName", ",", "$", "nodeData", "===", "true", "?", "'true'", ":", "'false'", ")", ";", "}", "else", "{", "$", "writer", "->", "writeElement", "(", "$", "nodeName", ",", "(", "string", ")", "$", "nodeData", ")", ";", "}", "}", "$", "writer", "->", "endElement", "(", ")", ";", "}" ]
Adds new child node to configuration XML @param string $name @param array $config @param \XMLWriter $writer
[ "Adds", "new", "child", "node", "to", "configuration", "XML" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Config/Writer/Xml.php#L62-L79
8,466
dazarobbo/Cola
src/Api/Json/Request.php
Request.get
public static function get() { $req = new static(); $post = \file_get_contents('php://input'); if($post !== false){ $obj = Json::deserialise($post); if($obj !== null){ $req->_Obj = $obj; } } return $req; }
php
public static function get() { $req = new static(); $post = \file_get_contents('php://input'); if($post !== false){ $obj = Json::deserialise($post); if($obj !== null){ $req->_Obj = $obj; } } return $req; }
[ "public", "static", "function", "get", "(", ")", "{", "$", "req", "=", "new", "static", "(", ")", ";", "$", "post", "=", "\\", "file_get_contents", "(", "'php://input'", ")", ";", "if", "(", "$", "post", "!==", "false", ")", "{", "$", "obj", "=", "Json", "::", "deserialise", "(", "$", "post", ")", ";", "if", "(", "$", "obj", "!==", "null", ")", "{", "$", "req", "->", "_Obj", "=", "$", "obj", ";", "}", "}", "return", "$", "req", ";", "}" ]
Returns an instance for a request which is JSON-formatted @return \static
[ "Returns", "an", "instance", "for", "a", "request", "which", "is", "JSON", "-", "formatted" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/Api/Json/Request.php#L29-L44
8,467
tenside/core-bundle
src/Console/Application.php
Application.registerCommands
protected function registerCommands(OutputInterface $output) { $container = $this->kernel->getContainer(); foreach ($this->kernel->getBundles() as $bundle) { if ($bundle instanceof Bundle) { $bundle->registerCommands($this); } } if ($container->hasParameter('console.command.ids')) { foreach ($container->getParameter('console.command.ids') as $id) { $this->add($container->get($id)); } } $this->addComposerCommands(); /** @var ComposerJson $file */ $file = $container->get('tenside.composer_json'); // Add non-standard scripts as own commands - keep this last to ensure we do not override internal commands. if ($file->has('scripts')) { foreach (array_keys($file->get('scripts')) as $script) { if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) { if ($this->has($script)) { $output->writeln( sprintf( '<warning>' . 'A script named %s would override a native function and has been skipped' . '</warning>', $script ) ); continue; } $this->add(new ScriptAliasCommand($script)); } } } }
php
protected function registerCommands(OutputInterface $output) { $container = $this->kernel->getContainer(); foreach ($this->kernel->getBundles() as $bundle) { if ($bundle instanceof Bundle) { $bundle->registerCommands($this); } } if ($container->hasParameter('console.command.ids')) { foreach ($container->getParameter('console.command.ids') as $id) { $this->add($container->get($id)); } } $this->addComposerCommands(); /** @var ComposerJson $file */ $file = $container->get('tenside.composer_json'); // Add non-standard scripts as own commands - keep this last to ensure we do not override internal commands. if ($file->has('scripts')) { foreach (array_keys($file->get('scripts')) as $script) { if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) { if ($this->has($script)) { $output->writeln( sprintf( '<warning>' . 'A script named %s would override a native function and has been skipped' . '</warning>', $script ) ); continue; } $this->add(new ScriptAliasCommand($script)); } } } }
[ "protected", "function", "registerCommands", "(", "OutputInterface", "$", "output", ")", "{", "$", "container", "=", "$", "this", "->", "kernel", "->", "getContainer", "(", ")", ";", "foreach", "(", "$", "this", "->", "kernel", "->", "getBundles", "(", ")", "as", "$", "bundle", ")", "{", "if", "(", "$", "bundle", "instanceof", "Bundle", ")", "{", "$", "bundle", "->", "registerCommands", "(", "$", "this", ")", ";", "}", "}", "if", "(", "$", "container", "->", "hasParameter", "(", "'console.command.ids'", ")", ")", "{", "foreach", "(", "$", "container", "->", "getParameter", "(", "'console.command.ids'", ")", "as", "$", "id", ")", "{", "$", "this", "->", "add", "(", "$", "container", "->", "get", "(", "$", "id", ")", ")", ";", "}", "}", "$", "this", "->", "addComposerCommands", "(", ")", ";", "/** @var ComposerJson $file */", "$", "file", "=", "$", "container", "->", "get", "(", "'tenside.composer_json'", ")", ";", "// Add non-standard scripts as own commands - keep this last to ensure we do not override internal commands.", "if", "(", "$", "file", "->", "has", "(", "'scripts'", ")", ")", "{", "foreach", "(", "array_keys", "(", "$", "file", "->", "get", "(", "'scripts'", ")", ")", "as", "$", "script", ")", "{", "if", "(", "!", "defined", "(", "'Composer\\Script\\ScriptEvents::'", ".", "str_replace", "(", "'-'", ",", "'_'", ",", "strtoupper", "(", "$", "script", ")", ")", ")", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "script", ")", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'<warning>'", ".", "'A script named %s would override a native function and has been skipped'", ".", "'</warning>'", ",", "$", "script", ")", ")", ";", "continue", ";", "}", "$", "this", "->", "add", "(", "new", "ScriptAliasCommand", "(", "$", "script", ")", ")", ";", "}", "}", "}", "}" ]
Register all commands from the container and bundles in the application. @param OutputInterface $output The output handler to use. @return void
[ "Register", "all", "commands", "from", "the", "container", "and", "bundles", "in", "the", "application", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Console/Application.php#L204-L244
8,468
tenside/core-bundle
src/Console/Application.php
Application.addComposerCommands
protected function addComposerCommands() { $this->add(new ComposerCommand\AboutCommand()); $this->add(new ComposerCommand\ConfigCommand()); $this->add(new ComposerCommand\DependsCommand()); $this->add(new ComposerCommand\InitCommand()); $this->add(new ComposerCommand\InstallCommand()); $this->add(new ComposerCommand\CreateProjectCommand()); $this->add(new ComposerCommand\UpdateCommand()); $this->add(new ComposerCommand\SearchCommand()); $this->add(new ComposerCommand\ValidateCommand()); $this->add(new ComposerCommand\ShowCommand()); $this->add(new ComposerCommand\SuggestsCommand()); $this->add(new ComposerCommand\RequireCommand()); $this->add(new ComposerCommand\DumpAutoloadCommand()); $this->add(new ComposerCommand\StatusCommand()); $this->add(new ComposerCommand\ArchiveCommand()); $this->add(new ComposerCommand\DiagnoseCommand()); $this->add(new ComposerCommand\RunScriptCommand()); $this->add(new ComposerCommand\LicensesCommand()); $this->add(new ComposerCommand\GlobalCommand()); $this->add(new ComposerCommand\ClearCacheCommand()); $this->add(new ComposerCommand\RemoveCommand()); $this->add(new ComposerCommand\HomeCommand()); }
php
protected function addComposerCommands() { $this->add(new ComposerCommand\AboutCommand()); $this->add(new ComposerCommand\ConfigCommand()); $this->add(new ComposerCommand\DependsCommand()); $this->add(new ComposerCommand\InitCommand()); $this->add(new ComposerCommand\InstallCommand()); $this->add(new ComposerCommand\CreateProjectCommand()); $this->add(new ComposerCommand\UpdateCommand()); $this->add(new ComposerCommand\SearchCommand()); $this->add(new ComposerCommand\ValidateCommand()); $this->add(new ComposerCommand\ShowCommand()); $this->add(new ComposerCommand\SuggestsCommand()); $this->add(new ComposerCommand\RequireCommand()); $this->add(new ComposerCommand\DumpAutoloadCommand()); $this->add(new ComposerCommand\StatusCommand()); $this->add(new ComposerCommand\ArchiveCommand()); $this->add(new ComposerCommand\DiagnoseCommand()); $this->add(new ComposerCommand\RunScriptCommand()); $this->add(new ComposerCommand\LicensesCommand()); $this->add(new ComposerCommand\GlobalCommand()); $this->add(new ComposerCommand\ClearCacheCommand()); $this->add(new ComposerCommand\RemoveCommand()); $this->add(new ComposerCommand\HomeCommand()); }
[ "protected", "function", "addComposerCommands", "(", ")", "{", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "AboutCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "ConfigCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "DependsCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "InitCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "InstallCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "CreateProjectCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "UpdateCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "SearchCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "ValidateCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "ShowCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "SuggestsCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "RequireCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "DumpAutoloadCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "StatusCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "ArchiveCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "DiagnoseCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "RunScriptCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "LicensesCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "GlobalCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "ClearCacheCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "RemoveCommand", "(", ")", ")", ";", "$", "this", "->", "add", "(", "new", "ComposerCommand", "\\", "HomeCommand", "(", ")", ")", ";", "}" ]
Add the composer base commands. @return void
[ "Add", "the", "composer", "base", "commands", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Console/Application.php#L251-L275
8,469
tenside/core-bundle
src/Console/Application.php
Application.isUpdateNeeded
protected function isUpdateNeeded(InputInterface $input, OutputInterface $output) { if ('@warning_time@' !== Tenside::WARNING_TIME) { $commandName = ''; if ($name = $this->getCommandName($input)) { try { $commandName = $this->find($name)->getName(); } catch (\InvalidArgumentException $e) { // Swallow the exception. } } if ($commandName !== 'self-update' && $commandName !== 'selfupdate') { if (time() > Tenside::WARNING_TIME) { $output->writeln( sprintf( '<warning>Warning: This development build is over 30 days old. ' . 'It is recommended to update it by running "%s self-update" to get the latest version.' . '</warning>', $_SERVER['PHP_SELF'] ) ); return true; } } } return false; }
php
protected function isUpdateNeeded(InputInterface $input, OutputInterface $output) { if ('@warning_time@' !== Tenside::WARNING_TIME) { $commandName = ''; if ($name = $this->getCommandName($input)) { try { $commandName = $this->find($name)->getName(); } catch (\InvalidArgumentException $e) { // Swallow the exception. } } if ($commandName !== 'self-update' && $commandName !== 'selfupdate') { if (time() > Tenside::WARNING_TIME) { $output->writeln( sprintf( '<warning>Warning: This development build is over 30 days old. ' . 'It is recommended to update it by running "%s self-update" to get the latest version.' . '</warning>', $_SERVER['PHP_SELF'] ) ); return true; } } } return false; }
[ "protected", "function", "isUpdateNeeded", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "if", "(", "'@warning_time@'", "!==", "Tenside", "::", "WARNING_TIME", ")", "{", "$", "commandName", "=", "''", ";", "if", "(", "$", "name", "=", "$", "this", "->", "getCommandName", "(", "$", "input", ")", ")", "{", "try", "{", "$", "commandName", "=", "$", "this", "->", "find", "(", "$", "name", ")", "->", "getName", "(", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "// Swallow the exception.", "}", "}", "if", "(", "$", "commandName", "!==", "'self-update'", "&&", "$", "commandName", "!==", "'selfupdate'", ")", "{", "if", "(", "time", "(", ")", ">", "Tenside", "::", "WARNING_TIME", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'<warning>Warning: This development build is over 30 days old. '", ".", "'It is recommended to update it by running \"%s self-update\" to get the latest version.'", ".", "'</warning>'", ",", "$", "_SERVER", "[", "'PHP_SELF'", "]", ")", ")", ";", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Check if updating is needed. @param InputInterface $input The input interface. @param OutputInterface $output The output interface. @return bool @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName)
[ "Check", "if", "updating", "is", "needed", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Console/Application.php#L346-L374
8,470
atelierspierrot/library
src/Library/Helper/Text.php
Text.cut
public static function cut($string = '', $length = 120, $end_str = ' ...') { if (empty($string)) { return ''; } if (strlen($string) >= $length) { $stringint = substr($string, 0, $length); $last_space = strrpos($stringint, " "); $stringinter = substr($stringint, 0, $last_space).$end_str; if (strlen($stringinter) === strlen($end_str)) { $stringcut = $stringint.$end_str; } else { $stringcut = $stringinter; } } else { $stringcut = $string; } return $stringcut; }
php
public static function cut($string = '', $length = 120, $end_str = ' ...') { if (empty($string)) { return ''; } if (strlen($string) >= $length) { $stringint = substr($string, 0, $length); $last_space = strrpos($stringint, " "); $stringinter = substr($stringint, 0, $last_space).$end_str; if (strlen($stringinter) === strlen($end_str)) { $stringcut = $stringint.$end_str; } else { $stringcut = $stringinter; } } else { $stringcut = $string; } return $stringcut; }
[ "public", "static", "function", "cut", "(", "$", "string", "=", "''", ",", "$", "length", "=", "120", ",", "$", "end_str", "=", "' ...'", ")", "{", "if", "(", "empty", "(", "$", "string", ")", ")", "{", "return", "''", ";", "}", "if", "(", "strlen", "(", "$", "string", ")", ">=", "$", "length", ")", "{", "$", "stringint", "=", "substr", "(", "$", "string", ",", "0", ",", "$", "length", ")", ";", "$", "last_space", "=", "strrpos", "(", "$", "stringint", ",", "\" \"", ")", ";", "$", "stringinter", "=", "substr", "(", "$", "stringint", ",", "0", ",", "$", "last_space", ")", ".", "$", "end_str", ";", "if", "(", "strlen", "(", "$", "stringinter", ")", "===", "strlen", "(", "$", "end_str", ")", ")", "{", "$", "stringcut", "=", "$", "stringint", ".", "$", "end_str", ";", "}", "else", "{", "$", "stringcut", "=", "$", "stringinter", ";", "}", "}", "else", "{", "$", "stringcut", "=", "$", "string", ";", "}", "return", "$", "stringcut", ";", "}" ]
Truncate a string at a maximum length, adding it a suffix like '...' @param string $string The string to cut @param int $length The maximum length to keep (`120` by default) @param string $end_str The suffix to add if the string was cut (` ...` by default) @return string
[ "Truncate", "a", "string", "at", "a", "maximum", "length", "adding", "it", "a", "suffix", "like", "..." ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Text.php#L48-L66
8,471
atelierspierrot/library
src/Library/Helper/Text.php
Text.slugify
public static function slugify($string = '') { $string = preg_replace('~[^\\pL\d]+~u', '-', $string); if (function_exists('iconv')) { $string = iconv('utf-8', 'us-ascii//TRANSLIT', $string); } $string = preg_replace('~[^-\w]+~', '', strtolower(trim($string, '-'))); return $string; }
php
public static function slugify($string = '') { $string = preg_replace('~[^\\pL\d]+~u', '-', $string); if (function_exists('iconv')) { $string = iconv('utf-8', 'us-ascii//TRANSLIT', $string); } $string = preg_replace('~[^-\w]+~', '', strtolower(trim($string, '-'))); return $string; }
[ "public", "static", "function", "slugify", "(", "$", "string", "=", "''", ")", "{", "$", "string", "=", "preg_replace", "(", "'~[^\\\\pL\\d]+~u'", ",", "'-'", ",", "$", "string", ")", ";", "if", "(", "function_exists", "(", "'iconv'", ")", ")", "{", "$", "string", "=", "iconv", "(", "'utf-8'", ",", "'us-ascii//TRANSLIT'", ",", "$", "string", ")", ";", "}", "$", "string", "=", "preg_replace", "(", "'~[^-\\w]+~'", ",", "''", ",", "strtolower", "(", "trim", "(", "$", "string", ",", "'-'", ")", ")", ")", ";", "return", "$", "string", ";", "}" ]
Get a slugified string By Miguel Santirso (http://sourcecookbook.com/en/recipes/8/function-to-slugify-strings-in-php) @param string $string The string to format @return string
[ "Get", "a", "slugified", "string" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Text.php#L126-L134
8,472
atelierspierrot/library
src/Library/Helper/Text.php
Text.toCamelCase
public static function toCamelCase($name = '', $replace = '_', $capitalize_first_char = true) { if (empty($name)) { return ''; } if ($capitalize_first_char) { $name[0] = strtoupper($name[0]); } $func = create_function('$c', 'return strtoupper($c[1]);'); return trim(preg_replace_callback('#'.$replace.'([a-z])#', $func, $name), $replace); }
php
public static function toCamelCase($name = '', $replace = '_', $capitalize_first_char = true) { if (empty($name)) { return ''; } if ($capitalize_first_char) { $name[0] = strtoupper($name[0]); } $func = create_function('$c', 'return strtoupper($c[1]);'); return trim(preg_replace_callback('#'.$replace.'([a-z])#', $func, $name), $replace); }
[ "public", "static", "function", "toCamelCase", "(", "$", "name", "=", "''", ",", "$", "replace", "=", "'_'", ",", "$", "capitalize_first_char", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "return", "''", ";", "}", "if", "(", "$", "capitalize_first_char", ")", "{", "$", "name", "[", "0", "]", "=", "strtoupper", "(", "$", "name", "[", "0", "]", ")", ";", "}", "$", "func", "=", "create_function", "(", "'$c'", ",", "'return strtoupper($c[1]);'", ")", ";", "return", "trim", "(", "preg_replace_callback", "(", "'#'", ".", "$", "replace", ".", "'([a-z])#'", ",", "$", "func", ",", "$", "name", ")", ",", "$", "replace", ")", ";", "}" ]
Transform a name in CamelCase @param string $name The string to transform @param string $replace Replacement character @param bool $capitalize_first_char May the first letter be in upper case (default is `true`) @return string The CamelCase version of `$name`
[ "Transform", "a", "name", "in", "CamelCase" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Text.php#L155-L165
8,473
atelierspierrot/library
src/Library/Helper/Text.php
Text.fromCamelCase
public static function fromCamelCase($name = '', $replace = '_', $lowerize_first_char = true) { if (empty($name)) { return ''; } if ($lowerize_first_char) { $name[0] = strtolower($name[0]); } $func = create_function('$c', 'return "'.$replace.'" . strtolower($c[1]);'); return trim(preg_replace_callback('/([A-Z])/', $func, $name), $replace); }
php
public static function fromCamelCase($name = '', $replace = '_', $lowerize_first_char = true) { if (empty($name)) { return ''; } if ($lowerize_first_char) { $name[0] = strtolower($name[0]); } $func = create_function('$c', 'return "'.$replace.'" . strtolower($c[1]);'); return trim(preg_replace_callback('/([A-Z])/', $func, $name), $replace); }
[ "public", "static", "function", "fromCamelCase", "(", "$", "name", "=", "''", ",", "$", "replace", "=", "'_'", ",", "$", "lowerize_first_char", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "return", "''", ";", "}", "if", "(", "$", "lowerize_first_char", ")", "{", "$", "name", "[", "0", "]", "=", "strtolower", "(", "$", "name", "[", "0", "]", ")", ";", "}", "$", "func", "=", "create_function", "(", "'$c'", ",", "'return \"'", ".", "$", "replace", ".", "'\" . strtolower($c[1]);'", ")", ";", "return", "trim", "(", "preg_replace_callback", "(", "'/([A-Z])/'", ",", "$", "func", ",", "$", "name", ")", ",", "$", "replace", ")", ";", "}" ]
Transform a name from CamelCase to other @param string $name The string to transform @param string $replace Replacement character @param bool $lowerize_first_char May the first letter be in lower case (default is `true`) @return string The un-CamelCase version of `$name`
[ "Transform", "a", "name", "from", "CamelCase", "to", "other" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Text.php#L175-L185
8,474
Sowapps/orpheus-inputcontroller
src/InputController/Controller.php
Controller.fillValues
public function fillValues(&$values=array()) { $values['Controller'] = $this; $values['Request'] = $this->getRequest(); $values['Route'] = $this->getRoute(); }
php
public function fillValues(&$values=array()) { $values['Controller'] = $this; $values['Request'] = $this->getRequest(); $values['Route'] = $this->getRoute(); }
[ "public", "function", "fillValues", "(", "&", "$", "values", "=", "array", "(", ")", ")", "{", "$", "values", "[", "'Controller'", "]", "=", "$", "this", ";", "$", "values", "[", "'Request'", "]", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "values", "[", "'Route'", "]", "=", "$", "this", "->", "getRoute", "(", ")", ";", "}" ]
Fill array with default values @param array $values
[ "Fill", "array", "with", "default", "values" ]
91f848a42ac02ae4009ffb3e9a9b4e8c0731455e
https://github.com/Sowapps/orpheus-inputcontroller/blob/91f848a42ac02ae4009ffb3e9a9b4e8c0731455e/src/InputController/Controller.php#L184-L188
8,475
slickframework/orm
src/Mapper/Relation/HasMany.php
HasMany.add
public function add(EntityAdded $event) { $entity = $event->getEntity(); $table = $this->getParentTableName(); $pmk = $this->getParentPrimaryKey(); $value = $event->getCollection()->parentEntity()->getId(); Sql::createSql($this->getAdapter()) ->update($table) ->set([$this->getForeignKey() => $value]) ->where(["{$pmk} = :id" => [':id' => $entity->getId()]]) ->execute(); }
php
public function add(EntityAdded $event) { $entity = $event->getEntity(); $table = $this->getParentTableName(); $pmk = $this->getParentPrimaryKey(); $value = $event->getCollection()->parentEntity()->getId(); Sql::createSql($this->getAdapter()) ->update($table) ->set([$this->getForeignKey() => $value]) ->where(["{$pmk} = :id" => [':id' => $entity->getId()]]) ->execute(); }
[ "public", "function", "add", "(", "EntityAdded", "$", "event", ")", "{", "$", "entity", "=", "$", "event", "->", "getEntity", "(", ")", ";", "$", "table", "=", "$", "this", "->", "getParentTableName", "(", ")", ";", "$", "pmk", "=", "$", "this", "->", "getParentPrimaryKey", "(", ")", ";", "$", "value", "=", "$", "event", "->", "getCollection", "(", ")", "->", "parentEntity", "(", ")", "->", "getId", "(", ")", ";", "Sql", "::", "createSql", "(", "$", "this", "->", "getAdapter", "(", ")", ")", "->", "update", "(", "$", "table", ")", "->", "set", "(", "[", "$", "this", "->", "getForeignKey", "(", ")", "=>", "$", "value", "]", ")", "->", "where", "(", "[", "\"{$pmk} = :id\"", "=>", "[", "':id'", "=>", "$", "entity", "->", "getId", "(", ")", "]", "]", ")", "->", "execute", "(", ")", ";", "}" ]
Saves the relation foreign key upon entity add @param EntityAdded $event
[ "Saves", "the", "relation", "foreign", "key", "upon", "entity", "add" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/HasMany.php#L103-L114
8,476
slickframework/orm
src/Mapper/Relation/HasMany.php
HasMany.checkConditions
protected function checkConditions(Sql\Select $query) { if (null != $this->conditions) { $query->andWhere($this->conditions); } return $this; }
php
protected function checkConditions(Sql\Select $query) { if (null != $this->conditions) { $query->andWhere($this->conditions); } return $this; }
[ "protected", "function", "checkConditions", "(", "Sql", "\\", "Select", "$", "query", ")", "{", "if", "(", "null", "!=", "$", "this", "->", "conditions", ")", "{", "$", "query", "->", "andWhere", "(", "$", "this", "->", "conditions", ")", ";", "}", "return", "$", "this", ";", "}" ]
Check custom conditions @param Sql\Select $query @return self
[ "Check", "custom", "conditions" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/HasMany.php#L155-L161
8,477
slickframework/orm
src/Mapper/Relation/HasMany.php
HasMany.checkOrder
protected function checkOrder(Sql\Select $query) { $order = $this->getEntityDescriptor()->getPrimaryKey()->getField(); $order .= " DESC"; if (null != $this->order) { $order = $this->order; } $query->order($order); return $this; }
php
protected function checkOrder(Sql\Select $query) { $order = $this->getEntityDescriptor()->getPrimaryKey()->getField(); $order .= " DESC"; if (null != $this->order) { $order = $this->order; } $query->order($order); return $this; }
[ "protected", "function", "checkOrder", "(", "Sql", "\\", "Select", "$", "query", ")", "{", "$", "order", "=", "$", "this", "->", "getEntityDescriptor", "(", ")", "->", "getPrimaryKey", "(", ")", "->", "getField", "(", ")", ";", "$", "order", ".=", "\" DESC\"", ";", "if", "(", "null", "!=", "$", "this", "->", "order", ")", "{", "$", "order", "=", "$", "this", "->", "order", ";", "}", "$", "query", "->", "order", "(", "$", "order", ")", ";", "return", "$", "this", ";", "}" ]
Check custom order @param Sql\Select $query @return self
[ "Check", "custom", "order" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/HasMany.php#L169-L178
8,478
nubs/sensible
src/CommandFactory/CommandFactoryTrait.php
CommandFactoryTrait.getCommand
protected function getCommand(StrategyInterface $strategy) { $command = $strategy->get(); if ($command === null) { throw new Exception('Failed to locate a sensible command'); } return $command; }
php
protected function getCommand(StrategyInterface $strategy) { $command = $strategy->get(); if ($command === null) { throw new Exception('Failed to locate a sensible command'); } return $command; }
[ "protected", "function", "getCommand", "(", "StrategyInterface", "$", "strategy", ")", "{", "$", "command", "=", "$", "strategy", "->", "get", "(", ")", ";", "if", "(", "$", "command", "===", "null", ")", "{", "throw", "new", "Exception", "(", "'Failed to locate a sensible command'", ")", ";", "}", "return", "$", "command", ";", "}" ]
Execute the strategy and return the command. @param \Nubs\Sensible\Strategy\StrategyInterface $strategy The strategy to locate a command with. @return string The command to execute. @throws \Exception if the strategy fails to find a command.
[ "Execute", "the", "strategy", "and", "return", "the", "command", "." ]
d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7
https://github.com/nubs/sensible/blob/d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7/src/CommandFactory/CommandFactoryTrait.php#L20-L28
8,479
eix/core
src/php/main/Eix/Services/Net/Http.php
Http.request
protected function request($method, $url, $parameters = array()) { Logger::get()->debug('HTTP: starting request...'); $headers = $this->headers; // Add accepted content type header. $headers[] = 'Content-Type: ' . $this->contentType; $headers[] = 'Accept: ' . $this->acceptedContentType; $handler = curl_init(); if (!is_null($this->user)) { curl_setopt($handler, CURLOPT_USERPWD, $this->user . ':' . $this->password); } Logger::get()->debug('HTTP: method is ' . $method); switch ($method) { case self::METHOD_DELETE: curl_setopt($handler, CURLOPT_URL, $url . '?' . http_build_query($parameters)); curl_setopt($handler, CURLOPT_CUSTOMREQUEST, self::DELETE); break; case self::METHOD_POST: curl_setopt($handler, CURLOPT_URL, $url); curl_setopt($handler, CURLOPT_POST, true); curl_setopt($handler, CURLOPT_POSTFIELDS, $parameters); break; case self::METHOD_GET: curl_setopt($handler, CURLOPT_URL, $url . '?' . http_build_query($parameters)); break; } curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); curl_setopt($handler, CURLOPT_HTTPHEADER, $headers); Logger::get()->debug('HTTP: headers set.'); // Send the request to the server. Logger::get()->debug("HTTP: requesting $url..."); $output = curl_exec($handler); $errNo = curl_errno($handler); $error = curl_error($handler); // Obtain the status. Logger::get()->debug('HTTP: Done. Getting status...'); $status = curl_getinfo($handler, CURLINFO_HTTP_CODE); // The handler is no longer needed. curl_close($handler); Logger::get()->debug('HTTP: request finished.'); if ($errNo) { throw new Exception('HTTP: cURL failed: ' . $error, $errNo); } // If cURL had no errors itself, then there is an HTTP response. switch ($status) { case self::STATUS_OK: case self::STATUS_CREATED: case self::STATUS_ACCEPTED: case self::STATUS_NO_CONTENT: return $output; default: throw new Http\Exception("HTTP {$status}", $status); } }
php
protected function request($method, $url, $parameters = array()) { Logger::get()->debug('HTTP: starting request...'); $headers = $this->headers; // Add accepted content type header. $headers[] = 'Content-Type: ' . $this->contentType; $headers[] = 'Accept: ' . $this->acceptedContentType; $handler = curl_init(); if (!is_null($this->user)) { curl_setopt($handler, CURLOPT_USERPWD, $this->user . ':' . $this->password); } Logger::get()->debug('HTTP: method is ' . $method); switch ($method) { case self::METHOD_DELETE: curl_setopt($handler, CURLOPT_URL, $url . '?' . http_build_query($parameters)); curl_setopt($handler, CURLOPT_CUSTOMREQUEST, self::DELETE); break; case self::METHOD_POST: curl_setopt($handler, CURLOPT_URL, $url); curl_setopt($handler, CURLOPT_POST, true); curl_setopt($handler, CURLOPT_POSTFIELDS, $parameters); break; case self::METHOD_GET: curl_setopt($handler, CURLOPT_URL, $url . '?' . http_build_query($parameters)); break; } curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); curl_setopt($handler, CURLOPT_HTTPHEADER, $headers); Logger::get()->debug('HTTP: headers set.'); // Send the request to the server. Logger::get()->debug("HTTP: requesting $url..."); $output = curl_exec($handler); $errNo = curl_errno($handler); $error = curl_error($handler); // Obtain the status. Logger::get()->debug('HTTP: Done. Getting status...'); $status = curl_getinfo($handler, CURLINFO_HTTP_CODE); // The handler is no longer needed. curl_close($handler); Logger::get()->debug('HTTP: request finished.'); if ($errNo) { throw new Exception('HTTP: cURL failed: ' . $error, $errNo); } // If cURL had no errors itself, then there is an HTTP response. switch ($status) { case self::STATUS_OK: case self::STATUS_CREATED: case self::STATUS_ACCEPTED: case self::STATUS_NO_CONTENT: return $output; default: throw new Http\Exception("HTTP {$status}", $status); } }
[ "protected", "function", "request", "(", "$", "method", ",", "$", "url", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "Logger", "::", "get", "(", ")", "->", "debug", "(", "'HTTP: starting request...'", ")", ";", "$", "headers", "=", "$", "this", "->", "headers", ";", "// Add accepted content type header.", "$", "headers", "[", "]", "=", "'Content-Type: '", ".", "$", "this", "->", "contentType", ";", "$", "headers", "[", "]", "=", "'Accept: '", ".", "$", "this", "->", "acceptedContentType", ";", "$", "handler", "=", "curl_init", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "user", ")", ")", "{", "curl_setopt", "(", "$", "handler", ",", "CURLOPT_USERPWD", ",", "$", "this", "->", "user", ".", "':'", ".", "$", "this", "->", "password", ")", ";", "}", "Logger", "::", "get", "(", ")", "->", "debug", "(", "'HTTP: method is '", ".", "$", "method", ")", ";", "switch", "(", "$", "method", ")", "{", "case", "self", "::", "METHOD_DELETE", ":", "curl_setopt", "(", "$", "handler", ",", "CURLOPT_URL", ",", "$", "url", ".", "'?'", ".", "http_build_query", "(", "$", "parameters", ")", ")", ";", "curl_setopt", "(", "$", "handler", ",", "CURLOPT_CUSTOMREQUEST", ",", "self", "::", "DELETE", ")", ";", "break", ";", "case", "self", "::", "METHOD_POST", ":", "curl_setopt", "(", "$", "handler", ",", "CURLOPT_URL", ",", "$", "url", ")", ";", "curl_setopt", "(", "$", "handler", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "handler", ",", "CURLOPT_POSTFIELDS", ",", "$", "parameters", ")", ";", "break", ";", "case", "self", "::", "METHOD_GET", ":", "curl_setopt", "(", "$", "handler", ",", "CURLOPT_URL", ",", "$", "url", ".", "'?'", ".", "http_build_query", "(", "$", "parameters", ")", ")", ";", "break", ";", "}", "curl_setopt", "(", "$", "handler", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "handler", ",", "CURLOPT_HTTPHEADER", ",", "$", "headers", ")", ";", "Logger", "::", "get", "(", ")", "->", "debug", "(", "'HTTP: headers set.'", ")", ";", "// Send the request to the server.", "Logger", "::", "get", "(", ")", "->", "debug", "(", "\"HTTP: requesting $url...\"", ")", ";", "$", "output", "=", "curl_exec", "(", "$", "handler", ")", ";", "$", "errNo", "=", "curl_errno", "(", "$", "handler", ")", ";", "$", "error", "=", "curl_error", "(", "$", "handler", ")", ";", "// Obtain the status.", "Logger", "::", "get", "(", ")", "->", "debug", "(", "'HTTP: Done. Getting status...'", ")", ";", "$", "status", "=", "curl_getinfo", "(", "$", "handler", ",", "CURLINFO_HTTP_CODE", ")", ";", "// The handler is no longer needed.", "curl_close", "(", "$", "handler", ")", ";", "Logger", "::", "get", "(", ")", "->", "debug", "(", "'HTTP: request finished.'", ")", ";", "if", "(", "$", "errNo", ")", "{", "throw", "new", "Exception", "(", "'HTTP: cURL failed: '", ".", "$", "error", ",", "$", "errNo", ")", ";", "}", "// If cURL had no errors itself, then there is an HTTP response.", "switch", "(", "$", "status", ")", "{", "case", "self", "::", "STATUS_OK", ":", "case", "self", "::", "STATUS_CREATED", ":", "case", "self", "::", "STATUS_ACCEPTED", ":", "case", "self", "::", "STATUS_NO_CONTENT", ":", "return", "$", "output", ";", "default", ":", "throw", "new", "Http", "\\", "Exception", "(", "\"HTTP {$status}\"", ",", "$", "status", ")", ";", "}", "}" ]
Performs the actual request. @param string $method @param string $url @param array $parameters @return string
[ "Performs", "the", "actual", "request", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Services/Net/Http.php#L181-L242
8,480
sbruggmann/WebExcess.Flow.Backup
Classes/WebExcess/Flow/Backup/Service/BackupService.php
BackupService.generateKeyFile
public function generateKeyFile() { $this->output->outputLine(); if ( file_exists($this->createFilePath([$this->localBackupTarget, 'key'])) ) { $this->output->outputLine('<b>You have already a keyfile!</b>'); $this->output->outputLine('If you generate a new one, all existing Backups are worthless.'); $this->output->outputLine(); $this->output->outputLine('Call \'./flow backup:clear --force\' to delete all Backups and the Keyfile.'); $this->output->outputLine(); return; } $this->output->outputLine('<b>Generate a new Crypto Key</b>'); $this->output->outputLine(); $this->files->createDirectoryRecursively($this->localBackupTarget); try { $key = \Crypto::createNewRandomKey(); file_put_contents($this->createFilePath([$this->localBackupTarget, 'key']), $key); // WARNING: Do NOT encode $key with bin2hex() or base64_encode(), // they may leak the key to the attacker through side channels. } catch (Ex\CryptoTestFailedException $ex) { die('Cannot safely create a key'); } catch (Ex\CannotPerformOperationException $ex) { die('Cannot safely create a key'); } $this->output->outputLine('done'); $this->output->outputLine(); }
php
public function generateKeyFile() { $this->output->outputLine(); if ( file_exists($this->createFilePath([$this->localBackupTarget, 'key'])) ) { $this->output->outputLine('<b>You have already a keyfile!</b>'); $this->output->outputLine('If you generate a new one, all existing Backups are worthless.'); $this->output->outputLine(); $this->output->outputLine('Call \'./flow backup:clear --force\' to delete all Backups and the Keyfile.'); $this->output->outputLine(); return; } $this->output->outputLine('<b>Generate a new Crypto Key</b>'); $this->output->outputLine(); $this->files->createDirectoryRecursively($this->localBackupTarget); try { $key = \Crypto::createNewRandomKey(); file_put_contents($this->createFilePath([$this->localBackupTarget, 'key']), $key); // WARNING: Do NOT encode $key with bin2hex() or base64_encode(), // they may leak the key to the attacker through side channels. } catch (Ex\CryptoTestFailedException $ex) { die('Cannot safely create a key'); } catch (Ex\CannotPerformOperationException $ex) { die('Cannot safely create a key'); } $this->output->outputLine('done'); $this->output->outputLine(); }
[ "public", "function", "generateKeyFile", "(", ")", "{", "$", "this", "->", "output", "->", "outputLine", "(", ")", ";", "if", "(", "file_exists", "(", "$", "this", "->", "createFilePath", "(", "[", "$", "this", "->", "localBackupTarget", ",", "'key'", "]", ")", ")", ")", "{", "$", "this", "->", "output", "->", "outputLine", "(", "'<b>You have already a keyfile!</b>'", ")", ";", "$", "this", "->", "output", "->", "outputLine", "(", "'If you generate a new one, all existing Backups are worthless.'", ")", ";", "$", "this", "->", "output", "->", "outputLine", "(", ")", ";", "$", "this", "->", "output", "->", "outputLine", "(", "'Call \\'./flow backup:clear --force\\' to delete all Backups and the Keyfile.'", ")", ";", "$", "this", "->", "output", "->", "outputLine", "(", ")", ";", "return", ";", "}", "$", "this", "->", "output", "->", "outputLine", "(", "'<b>Generate a new Crypto Key</b>'", ")", ";", "$", "this", "->", "output", "->", "outputLine", "(", ")", ";", "$", "this", "->", "files", "->", "createDirectoryRecursively", "(", "$", "this", "->", "localBackupTarget", ")", ";", "try", "{", "$", "key", "=", "\\", "Crypto", "::", "createNewRandomKey", "(", ")", ";", "file_put_contents", "(", "$", "this", "->", "createFilePath", "(", "[", "$", "this", "->", "localBackupTarget", ",", "'key'", "]", ")", ",", "$", "key", ")", ";", "// WARNING: Do NOT encode $key with bin2hex() or base64_encode(),", "// they may leak the key to the attacker through side channels.", "}", "catch", "(", "Ex", "\\", "CryptoTestFailedException", "$", "ex", ")", "{", "die", "(", "'Cannot safely create a key'", ")", ";", "}", "catch", "(", "Ex", "\\", "CannotPerformOperationException", "$", "ex", ")", "{", "die", "(", "'Cannot safely create a key'", ")", ";", "}", "$", "this", "->", "output", "->", "outputLine", "(", "'done'", ")", ";", "$", "this", "->", "output", "->", "outputLine", "(", ")", ";", "}" ]
Create a new Crypto Key File @return void
[ "Create", "a", "new", "Crypto", "Key", "File" ]
3165300c554da7ef9d67c4b5a7f1a22ba08035b4
https://github.com/sbruggmann/WebExcess.Flow.Backup/blob/3165300c554da7ef9d67c4b5a7f1a22ba08035b4/Classes/WebExcess/Flow/Backup/Service/BackupService.php#L372-L404
8,481
sbruggmann/WebExcess.Flow.Backup
Classes/WebExcess/Flow/Backup/Service/BackupService.php
BackupService.removeAllBackups
public function removeAllBackups() { $this->output->outputLine(); $this->output->outputLine('<b>Remove Backups</b>'); $this->output->outputLine(); $versions = $this->getAvailableVersions(); $this->output->progressStart(count($versions)); $i = 0; foreach ($versions as $version) { $this->files->removeDirectoryRecursively($this->createDirectoryPath([$this->localBackupTarget, $version])); $i++; $this->output->progressSet($i); } $this->output->progressFinish(); $this->output->outputLine(); }
php
public function removeAllBackups() { $this->output->outputLine(); $this->output->outputLine('<b>Remove Backups</b>'); $this->output->outputLine(); $versions = $this->getAvailableVersions(); $this->output->progressStart(count($versions)); $i = 0; foreach ($versions as $version) { $this->files->removeDirectoryRecursively($this->createDirectoryPath([$this->localBackupTarget, $version])); $i++; $this->output->progressSet($i); } $this->output->progressFinish(); $this->output->outputLine(); }
[ "public", "function", "removeAllBackups", "(", ")", "{", "$", "this", "->", "output", "->", "outputLine", "(", ")", ";", "$", "this", "->", "output", "->", "outputLine", "(", "'<b>Remove Backups</b>'", ")", ";", "$", "this", "->", "output", "->", "outputLine", "(", ")", ";", "$", "versions", "=", "$", "this", "->", "getAvailableVersions", "(", ")", ";", "$", "this", "->", "output", "->", "progressStart", "(", "count", "(", "$", "versions", ")", ")", ";", "$", "i", "=", "0", ";", "foreach", "(", "$", "versions", "as", "$", "version", ")", "{", "$", "this", "->", "files", "->", "removeDirectoryRecursively", "(", "$", "this", "->", "createDirectoryPath", "(", "[", "$", "this", "->", "localBackupTarget", ",", "$", "version", "]", ")", ")", ";", "$", "i", "++", ";", "$", "this", "->", "output", "->", "progressSet", "(", "$", "i", ")", ";", "}", "$", "this", "->", "output", "->", "progressFinish", "(", ")", ";", "$", "this", "->", "output", "->", "outputLine", "(", ")", ";", "}" ]
Remove all Backup Versions @return void
[ "Remove", "all", "Backup", "Versions" ]
3165300c554da7ef9d67c4b5a7f1a22ba08035b4
https://github.com/sbruggmann/WebExcess.Flow.Backup/blob/3165300c554da7ef9d67c4b5a7f1a22ba08035b4/Classes/WebExcess/Flow/Backup/Service/BackupService.php#L734-L751
8,482
polderknowledge/entityservice
src/Repository/Doctrine/ORMRepository.php
ORMRepository.deleteBy
public function deleteBy($criteria) { $criteria = Util::normalizeCriteria($criteria); $queryBuilder = $this->getQueryBuilder($criteria); $queryBuilder->delete($this->entityName, 'e'); $queryBuilder->getQuery()->execute(); }
php
public function deleteBy($criteria) { $criteria = Util::normalizeCriteria($criteria); $queryBuilder = $this->getQueryBuilder($criteria); $queryBuilder->delete($this->entityName, 'e'); $queryBuilder->getQuery()->execute(); }
[ "public", "function", "deleteBy", "(", "$", "criteria", ")", "{", "$", "criteria", "=", "Util", "::", "normalizeCriteria", "(", "$", "criteria", ")", ";", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", "$", "criteria", ")", ";", "$", "queryBuilder", "->", "delete", "(", "$", "this", "->", "entityName", ",", "'e'", ")", ";", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "execute", "(", ")", ";", "}" ]
Removes objects by a set of criteria. @param array|Criteria $criteria @return void @throws \Doctrine\ORM\Query\QueryException
[ "Removes", "objects", "by", "a", "set", "of", "criteria", "." ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/Repository/Doctrine/ORMRepository.php#L121-L128
8,483
polderknowledge/entityservice
src/Repository/Doctrine/ORMRepository.php
ORMRepository.findBy
public function findBy($criteria) { $criteria = Util::normalizeCriteria($criteria); $queryBuilder = $this->getQueryBuilder($criteria); return $queryBuilder->getQuery()->getResult(); }
php
public function findBy($criteria) { $criteria = Util::normalizeCriteria($criteria); $queryBuilder = $this->getQueryBuilder($criteria); return $queryBuilder->getQuery()->getResult(); }
[ "public", "function", "findBy", "(", "$", "criteria", ")", "{", "$", "criteria", "=", "Util", "::", "normalizeCriteria", "(", "$", "criteria", ")", ";", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", "$", "criteria", ")", ";", "return", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
Tries to find entities by a set of criteria. Optionally sorting and limiting details can be passed. An implementation may throw an UnexpectedValueException if certain values of the sorting or limiting details are not supported. @param array|Criteria $criteria The criteria to find entities by. @return array Returns an array with found entities. Returns an empty array when no entities are found. @throws \Doctrine\ORM\Query\QueryException @throws UnexpectedValueException Thrown when provided parameters are not supported.
[ "Tries", "to", "find", "entities", "by", "a", "set", "of", "criteria", "." ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/Repository/Doctrine/ORMRepository.php#L162-L169
8,484
polderknowledge/entityservice
src/Repository/Doctrine/ORMRepository.php
ORMRepository.findOneBy
public function findOneBy($criteria) { $criteria = Util::normalizeCriteria($criteria); $criteria->setFirstResult(0); $criteria->setMaxResults(1); $queryBuilder = $this->getQueryBuilder($criteria); return $queryBuilder->getQuery()->getOneOrNullResult(); }
php
public function findOneBy($criteria) { $criteria = Util::normalizeCriteria($criteria); $criteria->setFirstResult(0); $criteria->setMaxResults(1); $queryBuilder = $this->getQueryBuilder($criteria); return $queryBuilder->getQuery()->getOneOrNullResult(); }
[ "public", "function", "findOneBy", "(", "$", "criteria", ")", "{", "$", "criteria", "=", "Util", "::", "normalizeCriteria", "(", "$", "criteria", ")", ";", "$", "criteria", "->", "setFirstResult", "(", "0", ")", ";", "$", "criteria", "->", "setMaxResults", "(", "1", ")", ";", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", "$", "criteria", ")", ";", "return", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getOneOrNullResult", "(", ")", ";", "}" ]
Tries to find a single entity by a set of criteria. @param array|Criteria $criteria The criteria. The criteria to find the entity by. @return object|null Returns the entity that is found or null when no entity is found. @throws \Doctrine\ORM\Query\QueryException @throws \Doctrine\ORM\NonUniqueResultException
[ "Tries", "to", "find", "a", "single", "entity", "by", "a", "set", "of", "criteria", "." ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/Repository/Doctrine/ORMRepository.php#L179-L189
8,485
polderknowledge/entityservice
src/Repository/Doctrine/ORMRepository.php
ORMRepository.getRepository
public function getRepository() { if ($this->repository === null) { $this->repository = $this->entityManager->getRepository($this->entityName); } return $this->repository; }
php
public function getRepository() { if ($this->repository === null) { $this->repository = $this->entityManager->getRepository($this->entityName); } return $this->repository; }
[ "public", "function", "getRepository", "(", ")", "{", "if", "(", "$", "this", "->", "repository", "===", "null", ")", "{", "$", "this", "->", "repository", "=", "$", "this", "->", "entityManager", "->", "getRepository", "(", "$", "this", "->", "entityName", ")", ";", "}", "return", "$", "this", "->", "repository", ";", "}" ]
Returns the doctrine repository. @return ObjectRepository
[ "Returns", "the", "doctrine", "repository", "." ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/Repository/Doctrine/ORMRepository.php#L222-L229
8,486
kaecyra/app-common
src/FileConfig.php
FileConfig.app
public static function app($workingDir, $file) { $workingFile = rtrim($workingDir, '/').'/'.ltrim($file, '/'); return self::file($workingFile, true, true); }
php
public static function app($workingDir, $file) { $workingFile = rtrim($workingDir, '/').'/'.ltrim($file, '/'); return self::file($workingFile, true, true); }
[ "public", "static", "function", "app", "(", "$", "workingDir", ",", "$", "file", ")", "{", "$", "workingFile", "=", "rtrim", "(", "$", "workingDir", ",", "'/'", ")", ".", "'/'", ".", "ltrim", "(", "$", "file", ",", "'/'", ")", ";", "return", "self", "::", "file", "(", "$", "workingFile", ",", "true", ",", "true", ")", ";", "}" ]
Special config shortcut for application config @param string $workingDir @param string $file @return FileConfig
[ "Special", "config", "shortcut", "for", "application", "config" ]
8dbcf70c575fb587614b45da8ec02d098e3e843b
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/FileConfig.php#L60-L63
8,487
kaecyra/app-common
src/FileConfig.php
FileConfig.save
public function save($force = false) { if (!$this->writeable) { return false; } if (!$this->dirty && !$force) { return null; } $savetype = $force ? 'forced ' : ''; if (is_null($force)) { $savetype = 'auto '; } $path = dirname($this->file); if (!is_dir($path)) { mkdir($path, 0755, true); } $data = $this->store->dump(); $conf = version_compare(PHP_VERSION, '5.4', '>=') ? json_encode($data, JSON_PRETTY_PRINT) : json_encode($data); unset($data); if (!$conf || !json_decode($conf)) { return; } $saved = (bool)$this->writeAtomic($this->file, $conf, 0755); if ($saved) { $this->dirty = false; } return $saved; }
php
public function save($force = false) { if (!$this->writeable) { return false; } if (!$this->dirty && !$force) { return null; } $savetype = $force ? 'forced ' : ''; if (is_null($force)) { $savetype = 'auto '; } $path = dirname($this->file); if (!is_dir($path)) { mkdir($path, 0755, true); } $data = $this->store->dump(); $conf = version_compare(PHP_VERSION, '5.4', '>=') ? json_encode($data, JSON_PRETTY_PRINT) : json_encode($data); unset($data); if (!$conf || !json_decode($conf)) { return; } $saved = (bool)$this->writeAtomic($this->file, $conf, 0755); if ($saved) { $this->dirty = false; } return $saved; }
[ "public", "function", "save", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "writeable", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "dirty", "&&", "!", "$", "force", ")", "{", "return", "null", ";", "}", "$", "savetype", "=", "$", "force", "?", "'forced '", ":", "''", ";", "if", "(", "is_null", "(", "$", "force", ")", ")", "{", "$", "savetype", "=", "'auto '", ";", "}", "$", "path", "=", "dirname", "(", "$", "this", "->", "file", ")", ";", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "mkdir", "(", "$", "path", ",", "0755", ",", "true", ")", ";", "}", "$", "data", "=", "$", "this", "->", "store", "->", "dump", "(", ")", ";", "$", "conf", "=", "version_compare", "(", "PHP_VERSION", ",", "'5.4'", ",", "'>='", ")", "?", "json_encode", "(", "$", "data", ",", "JSON_PRETTY_PRINT", ")", ":", "json_encode", "(", "$", "data", ")", ";", "unset", "(", "$", "data", ")", ";", "if", "(", "!", "$", "conf", "||", "!", "json_decode", "(", "$", "conf", ")", ")", "{", "return", ";", "}", "$", "saved", "=", "(", "bool", ")", "$", "this", "->", "writeAtomic", "(", "$", "this", "->", "file", ",", "$", "conf", ",", "0755", ")", ";", "if", "(", "$", "saved", ")", "{", "$", "this", "->", "dirty", "=", "false", ";", "}", "return", "$", "saved", ";", "}" ]
Save config back to file @return boolean
[ "Save", "config", "back", "to", "file" ]
8dbcf70c575fb587614b45da8ec02d098e3e843b
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/FileConfig.php#L85-L117
8,488
kaecyra/app-common
src/FileConfig.php
FileConfig.writeAtomic
protected function writeAtomic($filename, $content, $mode) { $temp = tempnam(dirname($filename), 'atomic'); if (!($fp = @fopen($temp, 'wb'))) { $temp = dirname($filename) . '/' . uniqid('atomic'); if (!($fp = @fopen($temp, 'wb'))) { trigger_error(__METHOD__." : error writing temporary file '{$temp}'", E_USER_WARNING); return false; } } $br = fwrite($fp, $content); fclose($fp); if (!$br || $br != strlen($content)) { unlink($temp); return false; } chmod($temp, $mode); if (!rename($temp, $filename)) { unlink($filename); rename($temp, $filename); } return true; }
php
protected function writeAtomic($filename, $content, $mode) { $temp = tempnam(dirname($filename), 'atomic'); if (!($fp = @fopen($temp, 'wb'))) { $temp = dirname($filename) . '/' . uniqid('atomic'); if (!($fp = @fopen($temp, 'wb'))) { trigger_error(__METHOD__." : error writing temporary file '{$temp}'", E_USER_WARNING); return false; } } $br = fwrite($fp, $content); fclose($fp); if (!$br || $br != strlen($content)) { unlink($temp); return false; } chmod($temp, $mode); if (!rename($temp, $filename)) { unlink($filename); rename($temp, $filename); } return true; }
[ "protected", "function", "writeAtomic", "(", "$", "filename", ",", "$", "content", ",", "$", "mode", ")", "{", "$", "temp", "=", "tempnam", "(", "dirname", "(", "$", "filename", ")", ",", "'atomic'", ")", ";", "if", "(", "!", "(", "$", "fp", "=", "@", "fopen", "(", "$", "temp", ",", "'wb'", ")", ")", ")", "{", "$", "temp", "=", "dirname", "(", "$", "filename", ")", ".", "'/'", ".", "uniqid", "(", "'atomic'", ")", ";", "if", "(", "!", "(", "$", "fp", "=", "@", "fopen", "(", "$", "temp", ",", "'wb'", ")", ")", ")", "{", "trigger_error", "(", "__METHOD__", ".", "\" : error writing temporary file '{$temp}'\"", ",", "E_USER_WARNING", ")", ";", "return", "false", ";", "}", "}", "$", "br", "=", "fwrite", "(", "$", "fp", ",", "$", "content", ")", ";", "fclose", "(", "$", "fp", ")", ";", "if", "(", "!", "$", "br", "||", "$", "br", "!=", "strlen", "(", "$", "content", ")", ")", "{", "unlink", "(", "$", "temp", ")", ";", "return", "false", ";", "}", "chmod", "(", "$", "temp", ",", "$", "mode", ")", ";", "if", "(", "!", "rename", "(", "$", "temp", ",", "$", "filename", ")", ")", "{", "unlink", "(", "$", "filename", ")", ";", "rename", "(", "$", "temp", ",", "$", "filename", ")", ";", "}", "return", "true", ";", "}" ]
Write file atomically @param string $filename @param string $content @param octal $mode @return boolean
[ "Write", "file", "atomically" ]
8dbcf70c575fb587614b45da8ec02d098e3e843b
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/FileConfig.php#L127-L152
8,489
oroinc/OroChainProcessorComponent
Debug/TraceLogger.php
TraceLogger.getActions
public function getActions() { $actions = $this->actions; if (!empty($this->unclassifiedProcessors)) { $time = 0; foreach ($this->unclassifiedProcessors as $processor) { if (array_key_exists('time', $processor)) { $time += $processor['time']; } } $actions[] = [ 'name' => 'unclassified processors', 'time' => $time, 'processors' => $this->unclassifiedProcessors ]; } return $actions; }
php
public function getActions() { $actions = $this->actions; if (!empty($this->unclassifiedProcessors)) { $time = 0; foreach ($this->unclassifiedProcessors as $processor) { if (array_key_exists('time', $processor)) { $time += $processor['time']; } } $actions[] = [ 'name' => 'unclassified processors', 'time' => $time, 'processors' => $this->unclassifiedProcessors ]; } return $actions; }
[ "public", "function", "getActions", "(", ")", "{", "$", "actions", "=", "$", "this", "->", "actions", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "unclassifiedProcessors", ")", ")", "{", "$", "time", "=", "0", ";", "foreach", "(", "$", "this", "->", "unclassifiedProcessors", "as", "$", "processor", ")", "{", "if", "(", "array_key_exists", "(", "'time'", ",", "$", "processor", ")", ")", "{", "$", "time", "+=", "$", "processor", "[", "'time'", "]", ";", "}", "}", "$", "actions", "[", "]", "=", "[", "'name'", "=>", "'unclassified processors'", ",", "'time'", "=>", "$", "time", ",", "'processors'", "=>", "$", "this", "->", "unclassifiedProcessors", "]", ";", "}", "return", "$", "actions", ";", "}" ]
Gets all executed actions @return array
[ "Gets", "all", "executed", "actions" ]
89c9bc60140292c9367a0c3178f760ecbcec6bd2
https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/Debug/TraceLogger.php#L61-L79
8,490
oroinc/OroChainProcessorComponent
Debug/TraceLogger.php
TraceLogger.getApplicableCheckers
public function getApplicableCheckers() { $applicableCheckers = []; foreach ($this->applicableCheckers as $className => $applicableChecker) { $applicableCheckers[] = [ 'class' => $className, 'time' => $applicableChecker['time'], 'count' => $applicableChecker['count'] ]; } return $applicableCheckers; }
php
public function getApplicableCheckers() { $applicableCheckers = []; foreach ($this->applicableCheckers as $className => $applicableChecker) { $applicableCheckers[] = [ 'class' => $className, 'time' => $applicableChecker['time'], 'count' => $applicableChecker['count'] ]; } return $applicableCheckers; }
[ "public", "function", "getApplicableCheckers", "(", ")", "{", "$", "applicableCheckers", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "applicableCheckers", "as", "$", "className", "=>", "$", "applicableChecker", ")", "{", "$", "applicableCheckers", "[", "]", "=", "[", "'class'", "=>", "$", "className", ",", "'time'", "=>", "$", "applicableChecker", "[", "'time'", "]", ",", "'count'", "=>", "$", "applicableChecker", "[", "'count'", "]", "]", ";", "}", "return", "$", "applicableCheckers", ";", "}" ]
Gets all executed applicable checkers @return array
[ "Gets", "all", "executed", "applicable", "checkers" ]
89c9bc60140292c9367a0c3178f760ecbcec6bd2
https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/Debug/TraceLogger.php#L86-L97
8,491
oroinc/OroChainProcessorComponent
Debug/TraceLogger.php
TraceLogger.startAction
public function startAction($actionName) { $startStopwatch = $this->stopwatch && empty($this->actionStack); $this->actionStack[] = ['name' => $actionName, 'time' => microtime(true), 'subtrahend' => 0]; $this->lastActionIndex++; if ($startStopwatch) { $this->stopwatch->start($this->getStopwatchName(), $this->sectionName); } }
php
public function startAction($actionName) { $startStopwatch = $this->stopwatch && empty($this->actionStack); $this->actionStack[] = ['name' => $actionName, 'time' => microtime(true), 'subtrahend' => 0]; $this->lastActionIndex++; if ($startStopwatch) { $this->stopwatch->start($this->getStopwatchName(), $this->sectionName); } }
[ "public", "function", "startAction", "(", "$", "actionName", ")", "{", "$", "startStopwatch", "=", "$", "this", "->", "stopwatch", "&&", "empty", "(", "$", "this", "->", "actionStack", ")", ";", "$", "this", "->", "actionStack", "[", "]", "=", "[", "'name'", "=>", "$", "actionName", ",", "'time'", "=>", "microtime", "(", "true", ")", ",", "'subtrahend'", "=>", "0", "]", ";", "$", "this", "->", "lastActionIndex", "++", ";", "if", "(", "$", "startStopwatch", ")", "{", "$", "this", "->", "stopwatch", "->", "start", "(", "$", "this", "->", "getStopwatchName", "(", ")", ",", "$", "this", "->", "sectionName", ")", ";", "}", "}" ]
Marks an action as started @param string $actionName
[ "Marks", "an", "action", "as", "started" ]
89c9bc60140292c9367a0c3178f760ecbcec6bd2
https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/Debug/TraceLogger.php#L104-L113
8,492
oroinc/OroChainProcessorComponent
Debug/TraceLogger.php
TraceLogger.stopAction
public function stopAction(\Exception $exception = null) { $action = array_pop($this->actionStack); $this->lastActionIndex--; $action['time'] = microtime(true) - $action['time'] - $action['subtrahend']; if (null !== $exception) { $action['exception'] = $exception->getMessage(); } unset($action['subtrahend']); $this->addSubtrahend($this->actionStack, $action['time']); $this->addSubtrahend($this->processorStack, $action['time']); $this->actions[] = $action; if (empty($this->actionStack) && $this->stopwatch) { $this->stopwatch->stop($this->getStopwatchName()); } }
php
public function stopAction(\Exception $exception = null) { $action = array_pop($this->actionStack); $this->lastActionIndex--; $action['time'] = microtime(true) - $action['time'] - $action['subtrahend']; if (null !== $exception) { $action['exception'] = $exception->getMessage(); } unset($action['subtrahend']); $this->addSubtrahend($this->actionStack, $action['time']); $this->addSubtrahend($this->processorStack, $action['time']); $this->actions[] = $action; if (empty($this->actionStack) && $this->stopwatch) { $this->stopwatch->stop($this->getStopwatchName()); } }
[ "public", "function", "stopAction", "(", "\\", "Exception", "$", "exception", "=", "null", ")", "{", "$", "action", "=", "array_pop", "(", "$", "this", "->", "actionStack", ")", ";", "$", "this", "->", "lastActionIndex", "--", ";", "$", "action", "[", "'time'", "]", "=", "microtime", "(", "true", ")", "-", "$", "action", "[", "'time'", "]", "-", "$", "action", "[", "'subtrahend'", "]", ";", "if", "(", "null", "!==", "$", "exception", ")", "{", "$", "action", "[", "'exception'", "]", "=", "$", "exception", "->", "getMessage", "(", ")", ";", "}", "unset", "(", "$", "action", "[", "'subtrahend'", "]", ")", ";", "$", "this", "->", "addSubtrahend", "(", "$", "this", "->", "actionStack", ",", "$", "action", "[", "'time'", "]", ")", ";", "$", "this", "->", "addSubtrahend", "(", "$", "this", "->", "processorStack", ",", "$", "action", "[", "'time'", "]", ")", ";", "$", "this", "->", "actions", "[", "]", "=", "$", "action", ";", "if", "(", "empty", "(", "$", "this", "->", "actionStack", ")", "&&", "$", "this", "->", "stopwatch", ")", "{", "$", "this", "->", "stopwatch", "->", "stop", "(", "$", "this", "->", "getStopwatchName", "(", ")", ")", ";", "}", "}" ]
Marks an action as stopped @param \Exception|null $exception
[ "Marks", "an", "action", "as", "stopped" ]
89c9bc60140292c9367a0c3178f760ecbcec6bd2
https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/Debug/TraceLogger.php#L120-L135
8,493
oroinc/OroChainProcessorComponent
Debug/TraceLogger.php
TraceLogger.stopProcessor
public function stopProcessor(\Exception $exception = null) { $processor = array_pop($this->processorStack); $processor['time'] = microtime(true) - $processor['time'] - $processor['subtrahend']; if (null !== $exception) { $processor['exception'] = $exception->getMessage(); } unset($processor['subtrahend']); if (!empty($this->actionStack)) { if (!array_key_exists('processors', $this->actionStack[$this->lastActionIndex])) { $this->actionStack[$this->lastActionIndex]['processors'] = [$processor]; } else { $this->actionStack[$this->lastActionIndex]['processors'][] = $processor; } } else { $this->unclassifiedProcessors[] = $processor; } }
php
public function stopProcessor(\Exception $exception = null) { $processor = array_pop($this->processorStack); $processor['time'] = microtime(true) - $processor['time'] - $processor['subtrahend']; if (null !== $exception) { $processor['exception'] = $exception->getMessage(); } unset($processor['subtrahend']); if (!empty($this->actionStack)) { if (!array_key_exists('processors', $this->actionStack[$this->lastActionIndex])) { $this->actionStack[$this->lastActionIndex]['processors'] = [$processor]; } else { $this->actionStack[$this->lastActionIndex]['processors'][] = $processor; } } else { $this->unclassifiedProcessors[] = $processor; } }
[ "public", "function", "stopProcessor", "(", "\\", "Exception", "$", "exception", "=", "null", ")", "{", "$", "processor", "=", "array_pop", "(", "$", "this", "->", "processorStack", ")", ";", "$", "processor", "[", "'time'", "]", "=", "microtime", "(", "true", ")", "-", "$", "processor", "[", "'time'", "]", "-", "$", "processor", "[", "'subtrahend'", "]", ";", "if", "(", "null", "!==", "$", "exception", ")", "{", "$", "processor", "[", "'exception'", "]", "=", "$", "exception", "->", "getMessage", "(", ")", ";", "}", "unset", "(", "$", "processor", "[", "'subtrahend'", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "actionStack", ")", ")", "{", "if", "(", "!", "array_key_exists", "(", "'processors'", ",", "$", "this", "->", "actionStack", "[", "$", "this", "->", "lastActionIndex", "]", ")", ")", "{", "$", "this", "->", "actionStack", "[", "$", "this", "->", "lastActionIndex", "]", "[", "'processors'", "]", "=", "[", "$", "processor", "]", ";", "}", "else", "{", "$", "this", "->", "actionStack", "[", "$", "this", "->", "lastActionIndex", "]", "[", "'processors'", "]", "[", "]", "=", "$", "processor", ";", "}", "}", "else", "{", "$", "this", "->", "unclassifiedProcessors", "[", "]", "=", "$", "processor", ";", "}", "}" ]
Marks a processor as stopped @param \Exception|null $exception
[ "Marks", "a", "processor", "as", "stopped" ]
89c9bc60140292c9367a0c3178f760ecbcec6bd2
https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/Debug/TraceLogger.php#L152-L170
8,494
oroinc/OroChainProcessorComponent
Debug/TraceLogger.php
TraceLogger.startApplicableChecker
public function startApplicableChecker($className) { if (isset($this->applicableCheckers[$className])) { $this->applicableCheckers[$className]['startTime'] = microtime(true); } else { $this->applicableCheckers[$className] = ['startTime' => microtime(true), 'time' => 0, 'count' => 0]; } $this->lastApplicableChecker = $className; }
php
public function startApplicableChecker($className) { if (isset($this->applicableCheckers[$className])) { $this->applicableCheckers[$className]['startTime'] = microtime(true); } else { $this->applicableCheckers[$className] = ['startTime' => microtime(true), 'time' => 0, 'count' => 0]; } $this->lastApplicableChecker = $className; }
[ "public", "function", "startApplicableChecker", "(", "$", "className", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "applicableCheckers", "[", "$", "className", "]", ")", ")", "{", "$", "this", "->", "applicableCheckers", "[", "$", "className", "]", "[", "'startTime'", "]", "=", "microtime", "(", "true", ")", ";", "}", "else", "{", "$", "this", "->", "applicableCheckers", "[", "$", "className", "]", "=", "[", "'startTime'", "=>", "microtime", "(", "true", ")", ",", "'time'", "=>", "0", ",", "'count'", "=>", "0", "]", ";", "}", "$", "this", "->", "lastApplicableChecker", "=", "$", "className", ";", "}" ]
Marks an applicable checker as started @param string $className The class name of an applicable checker
[ "Marks", "an", "applicable", "checker", "as", "started" ]
89c9bc60140292c9367a0c3178f760ecbcec6bd2
https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/Debug/TraceLogger.php#L177-L185
8,495
oroinc/OroChainProcessorComponent
Debug/TraceLogger.php
TraceLogger.stopApplicableChecker
public function stopApplicableChecker() { $this->applicableCheckers[$this->lastApplicableChecker]['time'] += microtime(true) - $this->applicableCheckers[$this->lastApplicableChecker]['startTime']; $this->applicableCheckers[$this->lastApplicableChecker]['count'] += 1; }
php
public function stopApplicableChecker() { $this->applicableCheckers[$this->lastApplicableChecker]['time'] += microtime(true) - $this->applicableCheckers[$this->lastApplicableChecker]['startTime']; $this->applicableCheckers[$this->lastApplicableChecker]['count'] += 1; }
[ "public", "function", "stopApplicableChecker", "(", ")", "{", "$", "this", "->", "applicableCheckers", "[", "$", "this", "->", "lastApplicableChecker", "]", "[", "'time'", "]", "+=", "microtime", "(", "true", ")", "-", "$", "this", "->", "applicableCheckers", "[", "$", "this", "->", "lastApplicableChecker", "]", "[", "'startTime'", "]", ";", "$", "this", "->", "applicableCheckers", "[", "$", "this", "->", "lastApplicableChecker", "]", "[", "'count'", "]", "+=", "1", ";", "}" ]
Marks an applicable checker as stopped
[ "Marks", "an", "applicable", "checker", "as", "stopped" ]
89c9bc60140292c9367a0c3178f760ecbcec6bd2
https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/Debug/TraceLogger.php#L190-L195
8,496
crip-laravel/core
src/Events/EventCollector.php
EventCollector.push
public function push(array $results, $name = false) { $this->event_results = array_merge($this->event_results, $results); if ($name) { $this->event_names[] = $name; } return $this; }
php
public function push(array $results, $name = false) { $this->event_results = array_merge($this->event_results, $results); if ($name) { $this->event_names[] = $name; } return $this; }
[ "public", "function", "push", "(", "array", "$", "results", ",", "$", "name", "=", "false", ")", "{", "$", "this", "->", "event_results", "=", "array_merge", "(", "$", "this", "->", "event_results", ",", "$", "results", ")", ";", "if", "(", "$", "name", ")", "{", "$", "this", "->", "event_names", "[", "]", "=", "$", "name", ";", "}", "return", "$", "this", ";", "}" ]
Push event results to collection @param array $results @param string|bool $name @return $this
[ "Push", "event", "results", "to", "collection" ]
d58cef97d97fba8b01bec33801452ecbd7c992de
https://github.com/crip-laravel/core/blob/d58cef97d97fba8b01bec33801452ecbd7c992de/src/Events/EventCollector.php#L40-L49
8,497
tonjoo/tiga-framework
src/Html/HtmlBuilder.php
HtmlBuilder.entities
public function entities($value) { if (is_array($value)) { $newValue = array(); foreach ($value as $key => $val) { $newValue[$key] = htmlentities($val, ENT_QUOTES, 'UTF-8', false); } return $newValue; } return htmlentities($value, ENT_QUOTES, 'UTF-8', false); }
php
public function entities($value) { if (is_array($value)) { $newValue = array(); foreach ($value as $key => $val) { $newValue[$key] = htmlentities($val, ENT_QUOTES, 'UTF-8', false); } return $newValue; } return htmlentities($value, ENT_QUOTES, 'UTF-8', false); }
[ "public", "function", "entities", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "newValue", "=", "array", "(", ")", ";", "foreach", "(", "$", "value", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "newValue", "[", "$", "key", "]", "=", "htmlentities", "(", "$", "val", ",", "ENT_QUOTES", ",", "'UTF-8'", ",", "false", ")", ";", "}", "return", "$", "newValue", ";", "}", "return", "htmlentities", "(", "$", "value", ",", "ENT_QUOTES", ",", "'UTF-8'", ",", "false", ")", ";", "}" ]
Convert an HTML string to entities. @param string $value @return string
[ "Convert", "an", "HTML", "string", "to", "entities", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Html/HtmlBuilder.php#L21-L33
8,498
tonjoo/tiga-framework
src/Html/HtmlBuilder.php
HtmlBuilder.decode
public function decode($value) { if (is_array($value)) { $newValue = array(); foreach ($value as $key => $val) { $newValue[$key] = html_entity_decode($val, ENT_QUOTES, 'UTF-8'); } return $newValue; } return html_entity_decode($value, ENT_QUOTES, 'UTF-8'); }
php
public function decode($value) { if (is_array($value)) { $newValue = array(); foreach ($value as $key => $val) { $newValue[$key] = html_entity_decode($val, ENT_QUOTES, 'UTF-8'); } return $newValue; } return html_entity_decode($value, ENT_QUOTES, 'UTF-8'); }
[ "public", "function", "decode", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "newValue", "=", "array", "(", ")", ";", "foreach", "(", "$", "value", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "newValue", "[", "$", "key", "]", "=", "html_entity_decode", "(", "$", "val", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ";", "}", "return", "$", "newValue", ";", "}", "return", "html_entity_decode", "(", "$", "value", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ";", "}" ]
Convert entities to HTML characters. @param string $value @return string
[ "Convert", "entities", "to", "HTML", "characters", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Html/HtmlBuilder.php#L42-L54
8,499
99designs/ergo
classes/Ergo/Routing/Router.php
Router.connect
public function connect($template, $name, $controller=null, $metadata=array()) { if(is_object($template)) $this->_customRoutes[$name] = $template; else $this->_routes[$name] = new Route($name, $template); if($metadata) $this->_metadata[$name] = $metadata; if($controller) $this->_controllers[$name] = $controller; return $this; }
php
public function connect($template, $name, $controller=null, $metadata=array()) { if(is_object($template)) $this->_customRoutes[$name] = $template; else $this->_routes[$name] = new Route($name, $template); if($metadata) $this->_metadata[$name] = $metadata; if($controller) $this->_controllers[$name] = $controller; return $this; }
[ "public", "function", "connect", "(", "$", "template", ",", "$", "name", ",", "$", "controller", "=", "null", ",", "$", "metadata", "=", "array", "(", ")", ")", "{", "if", "(", "is_object", "(", "$", "template", ")", ")", "$", "this", "->", "_customRoutes", "[", "$", "name", "]", "=", "$", "template", ";", "else", "$", "this", "->", "_routes", "[", "$", "name", "]", "=", "new", "Route", "(", "$", "name", ",", "$", "template", ")", ";", "if", "(", "$", "metadata", ")", "$", "this", "->", "_metadata", "[", "$", "name", "]", "=", "$", "metadata", ";", "if", "(", "$", "controller", ")", "$", "this", "->", "_controllers", "[", "$", "name", "]", "=", "$", "controller", ";", "return", "$", "this", ";", "}" ]
Gives a route template a unique name and a controller to route to @param string a url template @param string a unique name for the route @param mixed a controller, either a class, a string or a callback @chainable
[ "Gives", "a", "route", "template", "a", "unique", "name", "and", "a", "controller", "to", "route", "to" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Routing/Router.php#L63-L77