id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
23,400
glynnforrest/blockade
src/Blockade/Firewall.php
Firewall.setPermissionNames
public function setPermissionNames($any, $none, $user, $anon) { if ($any) { $this->any = $any; } if ($none) { $this->none = $none; } if ($user) { $this->user = $user; } if ($anon) { $this->anon = $anon; } }
php
public function setPermissionNames($any, $none, $user, $anon) { if ($any) { $this->any = $any; } if ($none) { $this->none = $none; } if ($user) { $this->user = $user; } if ($anon) { $this->anon = $anon; } }
[ "public", "function", "setPermissionNames", "(", "$", "any", ",", "$", "none", ",", "$", "user", ",", "$", "anon", ")", "{", "if", "(", "$", "any", ")", "{", "$", "this", "->", "any", "=", "$", "any", ";", "}", "if", "(", "$", "none", ")", "{", "$", "this", "->", "none", "=", "$", "none", ";", "}", "if", "(", "$", "user", ")", "{", "$", "this", "->", "user", "=", "$", "user", ";", "}", "if", "(", "$", "anon", ")", "{", "$", "this", "->", "anon", "=", "$", "anon", ";", "}", "}" ]
Set the names of the permissions to use for any, none, user and anonymous rules. Set any of these to null to continue using the current name. @param string $any The rule that allows any request @param string $none The rule that blocks any request @param string $user The rule that allows any authentication @param string $anon The rule that allows anonymous access only
[ "Set", "the", "names", "of", "the", "permissions", "to", "use", "for", "any", "none", "user", "and", "anonymous", "rules", ".", "Set", "any", "of", "these", "to", "null", "to", "continue", "using", "the", "current", "name", "." ]
5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b
https://github.com/glynnforrest/blockade/blob/5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b/src/Blockade/Firewall.php#L79-L93
23,401
glynnforrest/blockade
src/Blockade/Firewall.php
Firewall.check
public function check(Request $request) { //first check the exemptions. If the request passes any of //these, skip all other rules and grant explicit access. foreach ($this->exemptions as $exemption) { try { if (true === $this->checkRule($request, $exemption)) { return true; } //catch any exceptions - a failed exemption shouldn't //fail the firewall entirely. Just move to on to the //next one. } catch (BlockadeException $e) {} } //check the rules. If they fail they will throw exceptions. foreach ($this->rules as $rule) { $this->checkRule($request, $rule); } //all rules have passed, but we can't be sure the request is //good as there may be other firewalls. Returning false is //this Firewall saying 'not sure' to the FirewallListener. return false; }
php
public function check(Request $request) { //first check the exemptions. If the request passes any of //these, skip all other rules and grant explicit access. foreach ($this->exemptions as $exemption) { try { if (true === $this->checkRule($request, $exemption)) { return true; } //catch any exceptions - a failed exemption shouldn't //fail the firewall entirely. Just move to on to the //next one. } catch (BlockadeException $e) {} } //check the rules. If they fail they will throw exceptions. foreach ($this->rules as $rule) { $this->checkRule($request, $rule); } //all rules have passed, but we can't be sure the request is //good as there may be other firewalls. Returning false is //this Firewall saying 'not sure' to the FirewallListener. return false; }
[ "public", "function", "check", "(", "Request", "$", "request", ")", "{", "//first check the exemptions. If the request passes any of", "//these, skip all other rules and grant explicit access.", "foreach", "(", "$", "this", "->", "exemptions", "as", "$", "exemption", ")", "{", "try", "{", "if", "(", "true", "===", "$", "this", "->", "checkRule", "(", "$", "request", ",", "$", "exemption", ")", ")", "{", "return", "true", ";", "}", "//catch any exceptions - a failed exemption shouldn't", "//fail the firewall entirely. Just move to on to the", "//next one.", "}", "catch", "(", "BlockadeException", "$", "e", ")", "{", "}", "}", "//check the rules. If they fail they will throw exceptions.", "foreach", "(", "$", "this", "->", "rules", "as", "$", "rule", ")", "{", "$", "this", "->", "checkRule", "(", "$", "request", ",", "$", "rule", ")", ";", "}", "//all rules have passed, but we can't be sure the request is", "//good as there may be other firewalls. Returning false is", "//this Firewall saying 'not sure' to the FirewallListener.", "return", "false", ";", "}" ]
Check if a Request has permission to access a resource. @param Request $request The request to check @return Boolean true if the request is granted explicit access via an exemption, false if the request passed but has not been granted explicit access (allowing other firewalls to check) @throws AuthenticationException if the request is not authenticated @throws AuthorizationException if the request is not authorized
[ "Check", "if", "a", "Request", "has", "permission", "to", "access", "a", "resource", "." ]
5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b
https://github.com/glynnforrest/blockade/blob/5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b/src/Blockade/Firewall.php#L117-L141
23,402
mmanos/laravel-casset
src/Mmanos/Casset/Compressors/Css.php
Css._commentCB
protected function _commentCB($m) { $hasSurroundingWs = (trim($m[0]) !== $m[1]); $m = $m[1]; // $m is the comment content w/o the surrounding tokens, // but the return value will replace the entire comment. if ($m === 'keep') { return '/**/'; } if ($m === '" "') { // component of http://tantek.com/CSS/Examples/midpass.html return '/*" "*/'; } if (preg_match('@";\\}\\s*\\}/\\*\\s+@', $m)) { // component of http://tantek.com/CSS/Examples/midpass.html return '/*";}}/* */'; } if ($this->_inHack) { // inversion: feeding only to one browser if (preg_match('@ ^/ # comment started like /*/ \\s* (\\S[\\s\\S]+?) # has at least some non-ws content \\s* /\\* # ends like /*/ or /**/ @x', $m, $n)) { // end hack mode after this comment, but preserve the hack and comment content $this->_inHack = false; return "/*/{$n[1]}/**/"; } } if (substr($m, -1) === '\\') { // comment ends like \*/ // begin hack mode and preserve hack $this->_inHack = true; return '/*\\*/'; } if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */ // begin hack mode and preserve hack $this->_inHack = true; return '/*/*/'; } if ($this->_inHack) { // a regular comment ends hack mode but should be preserved $this->_inHack = false; return '/**/'; } // Issue 107: if there's any surrounding whitespace, it may be important, so // replace the comment with a single space return $hasSurroundingWs // remove all other comments ? ' ' : ''; }
php
protected function _commentCB($m) { $hasSurroundingWs = (trim($m[0]) !== $m[1]); $m = $m[1]; // $m is the comment content w/o the surrounding tokens, // but the return value will replace the entire comment. if ($m === 'keep') { return '/**/'; } if ($m === '" "') { // component of http://tantek.com/CSS/Examples/midpass.html return '/*" "*/'; } if (preg_match('@";\\}\\s*\\}/\\*\\s+@', $m)) { // component of http://tantek.com/CSS/Examples/midpass.html return '/*";}}/* */'; } if ($this->_inHack) { // inversion: feeding only to one browser if (preg_match('@ ^/ # comment started like /*/ \\s* (\\S[\\s\\S]+?) # has at least some non-ws content \\s* /\\* # ends like /*/ or /**/ @x', $m, $n)) { // end hack mode after this comment, but preserve the hack and comment content $this->_inHack = false; return "/*/{$n[1]}/**/"; } } if (substr($m, -1) === '\\') { // comment ends like \*/ // begin hack mode and preserve hack $this->_inHack = true; return '/*\\*/'; } if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */ // begin hack mode and preserve hack $this->_inHack = true; return '/*/*/'; } if ($this->_inHack) { // a regular comment ends hack mode but should be preserved $this->_inHack = false; return '/**/'; } // Issue 107: if there's any surrounding whitespace, it may be important, so // replace the comment with a single space return $hasSurroundingWs // remove all other comments ? ' ' : ''; }
[ "protected", "function", "_commentCB", "(", "$", "m", ")", "{", "$", "hasSurroundingWs", "=", "(", "trim", "(", "$", "m", "[", "0", "]", ")", "!==", "$", "m", "[", "1", "]", ")", ";", "$", "m", "=", "$", "m", "[", "1", "]", ";", "// $m is the comment content w/o the surrounding tokens, ", "// but the return value will replace the entire comment.", "if", "(", "$", "m", "===", "'keep'", ")", "{", "return", "'/**/'", ";", "}", "if", "(", "$", "m", "===", "'\" \"'", ")", "{", "// component of http://tantek.com/CSS/Examples/midpass.html", "return", "'/*\" \"*/'", ";", "}", "if", "(", "preg_match", "(", "'@\";\\\\}\\\\s*\\\\}/\\\\*\\\\s+@'", ",", "$", "m", ")", ")", "{", "// component of http://tantek.com/CSS/Examples/midpass.html", "return", "'/*\";}}/* */'", ";", "}", "if", "(", "$", "this", "->", "_inHack", ")", "{", "// inversion: feeding only to one browser", "if", "(", "preg_match", "(", "'@\n ^/ # comment started like /*/\n \\\\s*\n (\\\\S[\\\\s\\\\S]+?) # has at least some non-ws content\n \\\\s*\n /\\\\* # ends like /*/ or /**/\n @x'", ",", "$", "m", ",", "$", "n", ")", ")", "{", "// end hack mode after this comment, but preserve the hack and comment content", "$", "this", "->", "_inHack", "=", "false", ";", "return", "\"/*/{$n[1]}/**/\"", ";", "}", "}", "if", "(", "substr", "(", "$", "m", ",", "-", "1", ")", "===", "'\\\\'", ")", "{", "// comment ends like \\*/", "// begin hack mode and preserve hack", "$", "this", "->", "_inHack", "=", "true", ";", "return", "'/*\\\\*/'", ";", "}", "if", "(", "$", "m", "!==", "''", "&&", "$", "m", "[", "0", "]", "===", "'/'", ")", "{", "// comment looks like /*/ foo */", "// begin hack mode and preserve hack", "$", "this", "->", "_inHack", "=", "true", ";", "return", "'/*/*/'", ";", "}", "if", "(", "$", "this", "->", "_inHack", ")", "{", "// a regular comment ends hack mode but should be preserved", "$", "this", "->", "_inHack", "=", "false", ";", "return", "'/**/'", ";", "}", "// Issue 107: if there's any surrounding whitespace, it may be important, so ", "// replace the comment with a single space", "return", "$", "hasSurroundingWs", "// remove all other comments", "?", "' '", ":", "''", ";", "}" ]
Process a comment and return a replacement @param array $m regex matches @return string
[ "Process", "a", "comment", "and", "return", "a", "replacement" ]
0f7db71211c1daa99bde30afa41da2692a39b81c
https://github.com/mmanos/laravel-casset/blob/0f7db71211c1daa99bde30afa41da2692a39b81c/src/Mmanos/Casset/Compressors/Css.php#L173-L224
23,403
netvlies/NetvliesFormBundle
EventListener/SubmitListener.php
SubmitListener.onKernelRequest
public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); if ($request->isMethod('post')) { $formId = $request->request->getInt('form[form_id]', 0, true); if ($formId > 0) { $form = $this->container->get('netvlies.form')->get($formId); $sf2Form = $form->getSf2Form(); $sf2Form->bind($request); if ($sf2Form->isValid()) { $form->setSuccess(true); $event = new FormEvent($form); $dispatcher = $this->container->get('event_dispatcher'); $dispatcher->dispatch('form.success', $event); } } } }
php
public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); if ($request->isMethod('post')) { $formId = $request->request->getInt('form[form_id]', 0, true); if ($formId > 0) { $form = $this->container->get('netvlies.form')->get($formId); $sf2Form = $form->getSf2Form(); $sf2Form->bind($request); if ($sf2Form->isValid()) { $form->setSuccess(true); $event = new FormEvent($form); $dispatcher = $this->container->get('event_dispatcher'); $dispatcher->dispatch('form.success', $event); } } } }
[ "public", "function", "onKernelRequest", "(", "GetResponseEvent", "$", "event", ")", "{", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "if", "(", "$", "request", "->", "isMethod", "(", "'post'", ")", ")", "{", "$", "formId", "=", "$", "request", "->", "request", "->", "getInt", "(", "'form[form_id]'", ",", "0", ",", "true", ")", ";", "if", "(", "$", "formId", ">", "0", ")", "{", "$", "form", "=", "$", "this", "->", "container", "->", "get", "(", "'netvlies.form'", ")", "->", "get", "(", "$", "formId", ")", ";", "$", "sf2Form", "=", "$", "form", "->", "getSf2Form", "(", ")", ";", "$", "sf2Form", "->", "bind", "(", "$", "request", ")", ";", "if", "(", "$", "sf2Form", "->", "isValid", "(", ")", ")", "{", "$", "form", "->", "setSuccess", "(", "true", ")", ";", "$", "event", "=", "new", "FormEvent", "(", "$", "form", ")", ";", "$", "dispatcher", "=", "$", "this", "->", "container", "->", "get", "(", "'event_dispatcher'", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "'form.success'", ",", "$", "event", ")", ";", "}", "}", "}", "}" ]
Checks if a form post request was mad. If so, it validates the form input and upon success dispatches the form success event, which can be used for further custom handling of the received data. @param $event
[ "Checks", "if", "a", "form", "post", "request", "was", "mad", ".", "If", "so", "it", "validates", "the", "form", "input", "and", "upon", "success", "dispatches", "the", "form", "success", "event", "which", "can", "be", "used", "for", "further", "custom", "handling", "of", "the", "received", "data", "." ]
93f9a3321d9925040111374e7c1014a6400a2d08
https://github.com/netvlies/NetvliesFormBundle/blob/93f9a3321d9925040111374e7c1014a6400a2d08/EventListener/SubmitListener.php#L27-L51
23,404
hametuha/wpametu
src/WPametu/Service/Akismet.php
Akismet.is_spam
public static function is_spam( array $values = [] ){ $query_string = self::make_request( $values ); // If Akismet is not active, always return error if( !class_exists('Akismet') || ! \Akismet::get_api_key() ){ return new \WP_Error(500, 'Akismet is not active.'); } // Make request add_filter('akismet_ua', [static::class, 'get_ua'], 9); $response = \Akismet::http_post($query_string, 'comment-check'); remove_filter('akismet_ua', [static::class, 'get_ua'], 9); // Parse result switch( $response[1] ){ case 'true': return true; // This is spam. break; case 'false': return false; // This is not spam. break; default: // Something is wrong if( isset( $response[0]['x-akismet-debug-help'] ) && !empty($response[0]['x-akismet-debug-help']) ){ $message = $response[0]['x-akismet-debug-help']; }else{ $message = 'Akismet return the invalid result. Something is wrong.'; } return new \WP_Error(500, $message); break; } }
php
public static function is_spam( array $values = [] ){ $query_string = self::make_request( $values ); // If Akismet is not active, always return error if( !class_exists('Akismet') || ! \Akismet::get_api_key() ){ return new \WP_Error(500, 'Akismet is not active.'); } // Make request add_filter('akismet_ua', [static::class, 'get_ua'], 9); $response = \Akismet::http_post($query_string, 'comment-check'); remove_filter('akismet_ua', [static::class, 'get_ua'], 9); // Parse result switch( $response[1] ){ case 'true': return true; // This is spam. break; case 'false': return false; // This is not spam. break; default: // Something is wrong if( isset( $response[0]['x-akismet-debug-help'] ) && !empty($response[0]['x-akismet-debug-help']) ){ $message = $response[0]['x-akismet-debug-help']; }else{ $message = 'Akismet return the invalid result. Something is wrong.'; } return new \WP_Error(500, $message); break; } }
[ "public", "static", "function", "is_spam", "(", "array", "$", "values", "=", "[", "]", ")", "{", "$", "query_string", "=", "self", "::", "make_request", "(", "$", "values", ")", ";", "// If Akismet is not active, always return error", "if", "(", "!", "class_exists", "(", "'Akismet'", ")", "||", "!", "\\", "Akismet", "::", "get_api_key", "(", ")", ")", "{", "return", "new", "\\", "WP_Error", "(", "500", ",", "'Akismet is not active.'", ")", ";", "}", "// Make request", "add_filter", "(", "'akismet_ua'", ",", "[", "static", "::", "class", ",", "'get_ua'", "]", ",", "9", ")", ";", "$", "response", "=", "\\", "Akismet", "::", "http_post", "(", "$", "query_string", ",", "'comment-check'", ")", ";", "remove_filter", "(", "'akismet_ua'", ",", "[", "static", "::", "class", ",", "'get_ua'", "]", ",", "9", ")", ";", "// Parse result", "switch", "(", "$", "response", "[", "1", "]", ")", "{", "case", "'true'", ":", "return", "true", ";", "// This is spam.", "break", ";", "case", "'false'", ":", "return", "false", ";", "// This is not spam.", "break", ";", "default", ":", "// Something is wrong", "if", "(", "isset", "(", "$", "response", "[", "0", "]", "[", "'x-akismet-debug-help'", "]", ")", "&&", "!", "empty", "(", "$", "response", "[", "0", "]", "[", "'x-akismet-debug-help'", "]", ")", ")", "{", "$", "message", "=", "$", "response", "[", "0", "]", "[", "'x-akismet-debug-help'", "]", ";", "}", "else", "{", "$", "message", "=", "'Akismet return the invalid result. Something is wrong.'", ";", "}", "return", "new", "\\", "WP_Error", "(", "500", ",", "$", "message", ")", ";", "break", ";", "}", "}" ]
Check if data is spam @param array $values @return bool|\WP_Error
[ "Check", "if", "data", "is", "spam" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Service/Akismet.php#L24-L52
23,405
hametuha/wpametu
src/WPametu/Service/Akismet.php
Akismet.make_request
public static function make_request( array $args = [] ){ $args = wp_parse_args([ 'blog' => get_option( 'home' ), 'blog_lang' => get_locale(), 'blog_charset' => get_option( 'blog_charset' ), 'user_ip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '', 'referrer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', ], $args); // Add server variables foreach ( $_SERVER as $key => $value ) { switch( $key ){ case 'REMOTE_ADDR': case 'HTTP_USER_AGENT': case 'HTTP_REFERER': case 'HTTP_COOKIE': case 'HTTP_COOKIE2': case 'PHP_AUTH_PW': // Ignore break; default: $args[$key] = $value; break; } } return http_build_query($args); }
php
public static function make_request( array $args = [] ){ $args = wp_parse_args([ 'blog' => get_option( 'home' ), 'blog_lang' => get_locale(), 'blog_charset' => get_option( 'blog_charset' ), 'user_ip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '', 'referrer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', ], $args); // Add server variables foreach ( $_SERVER as $key => $value ) { switch( $key ){ case 'REMOTE_ADDR': case 'HTTP_USER_AGENT': case 'HTTP_REFERER': case 'HTTP_COOKIE': case 'HTTP_COOKIE2': case 'PHP_AUTH_PW': // Ignore break; default: $args[$key] = $value; break; } } return http_build_query($args); }
[ "public", "static", "function", "make_request", "(", "array", "$", "args", "=", "[", "]", ")", "{", "$", "args", "=", "wp_parse_args", "(", "[", "'blog'", "=>", "get_option", "(", "'home'", ")", ",", "'blog_lang'", "=>", "get_locale", "(", ")", ",", "'blog_charset'", "=>", "get_option", "(", "'blog_charset'", ")", ",", "'user_ip'", "=>", "isset", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ")", "?", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ":", "''", ",", "'user_agent'", "=>", "isset", "(", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ")", "?", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ":", "''", ",", "'referrer'", "=>", "isset", "(", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ")", "?", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ":", "''", ",", "]", ",", "$", "args", ")", ";", "// Add server variables", "foreach", "(", "$", "_SERVER", "as", "$", "key", "=>", "$", "value", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "'REMOTE_ADDR'", ":", "case", "'HTTP_USER_AGENT'", ":", "case", "'HTTP_REFERER'", ":", "case", "'HTTP_COOKIE'", ":", "case", "'HTTP_COOKIE2'", ":", "case", "'PHP_AUTH_PW'", ":", "// Ignore", "break", ";", "default", ":", "$", "args", "[", "$", "key", "]", "=", "$", "value", ";", "break", ";", "}", "}", "return", "http_build_query", "(", "$", "args", ")", ";", "}" ]
Make request arguments @param array $args @return string
[ "Make", "request", "arguments" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Service/Akismet.php#L61-L87
23,406
surebert/surebert-framework
src/sb/Gitlab/Client.php
Client.get
public function get($url, $data = [], $method = 'post') { $ch = curl_init($this->gitlab_host . '/api/v3' . $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'PRIVATE-TOKEN:' . $this->private_key )); if($this->debug){ curl_setopt($ch, CURLOPT_VERBOSE, true); if(!\sb\Gateway::$command_line){ $curl_log = fopen("php://temp", 'rw'); curl_setopt($ch, CURLOPT_STDERR, $curl_log); } } curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if ($data) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); if ($method != 'post') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); } } $error = curl_error($ch); $error_no = curl_errno($ch); if ($error_no) { throw(new \Exception($error . ': ' . $error_no)); } $data = json_decode(curl_exec($ch)); if($this->debug && !\sb\Gateway::$command_line){ rewind($curl_log); $output= fread($curl_log, 2048); echo "<pre>". print_r($output, 1). "</pre>"; fclose($curl_log); } return $data; }
php
public function get($url, $data = [], $method = 'post') { $ch = curl_init($this->gitlab_host . '/api/v3' . $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'PRIVATE-TOKEN:' . $this->private_key )); if($this->debug){ curl_setopt($ch, CURLOPT_VERBOSE, true); if(!\sb\Gateway::$command_line){ $curl_log = fopen("php://temp", 'rw'); curl_setopt($ch, CURLOPT_STDERR, $curl_log); } } curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if ($data) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); if ($method != 'post') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); } } $error = curl_error($ch); $error_no = curl_errno($ch); if ($error_no) { throw(new \Exception($error . ': ' . $error_no)); } $data = json_decode(curl_exec($ch)); if($this->debug && !\sb\Gateway::$command_line){ rewind($curl_log); $output= fread($curl_log, 2048); echo "<pre>". print_r($output, 1). "</pre>"; fclose($curl_log); } return $data; }
[ "public", "function", "get", "(", "$", "url", ",", "$", "data", "=", "[", "]", ",", "$", "method", "=", "'post'", ")", "{", "$", "ch", "=", "curl_init", "(", "$", "this", "->", "gitlab_host", ".", "'/api/v3'", ".", "$", "url", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HEADER", ",", "0", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HTTPHEADER", ",", "array", "(", "'PRIVATE-TOKEN:'", ".", "$", "this", "->", "private_key", ")", ")", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_VERBOSE", ",", "true", ")", ";", "if", "(", "!", "\\", "sb", "\\", "Gateway", "::", "$", "command_line", ")", "{", "$", "curl_log", "=", "fopen", "(", "\"php://temp\"", ",", "'rw'", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_STDERR", ",", "$", "curl_log", ")", ";", "}", "}", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "if", "(", "$", "data", ")", "{", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "http_build_query", "(", "$", "data", ")", ")", ";", "if", "(", "$", "method", "!=", "'post'", ")", "{", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_CUSTOMREQUEST", ",", "$", "method", ")", ";", "}", "}", "$", "error", "=", "curl_error", "(", "$", "ch", ")", ";", "$", "error_no", "=", "curl_errno", "(", "$", "ch", ")", ";", "if", "(", "$", "error_no", ")", "{", "throw", "(", "new", "\\", "Exception", "(", "$", "error", ".", "': '", ".", "$", "error_no", ")", ")", ";", "}", "$", "data", "=", "json_decode", "(", "curl_exec", "(", "$", "ch", ")", ")", ";", "if", "(", "$", "this", "->", "debug", "&&", "!", "\\", "sb", "\\", "Gateway", "::", "$", "command_line", ")", "{", "rewind", "(", "$", "curl_log", ")", ";", "$", "output", "=", "fread", "(", "$", "curl_log", ",", "2048", ")", ";", "echo", "\"<pre>\"", ".", "print_r", "(", "$", "output", ",", "1", ")", ".", "\"</pre>\"", ";", "fclose", "(", "$", "curl_log", ")", ";", "}", "return", "$", "data", ";", "}" ]
GRabs data from a URL and json_decodes it @param string $url URL to grab @param array $data http data to pass @param string $method post, put delete, default post @return object @throws Exception
[ "GRabs", "data", "from", "a", "URL", "and", "json_decodes", "it" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Gitlab/Client.php#L63-L108
23,407
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/Example/Finder.php
Finder.getExampleFileContents
private function getExampleFileContents($filename) { $normalizedPath = null; foreach ($this->exampleDirectories as $directory) { $exampleFileFromConfig = $this->constructExamplePath($directory, $filename); if (is_readable($exampleFileFromConfig)) { $normalizedPath = $exampleFileFromConfig; break; } } if (! $normalizedPath) { if (is_readable($this->getExamplePathFromSource($filename))) { $normalizedPath = $this->getExamplePathFromSource($filename); } elseif (is_readable($this->getExamplePathFromExampleDirectory($filename))) { $normalizedPath = $this->getExamplePathFromExampleDirectory($filename); } elseif (is_readable($filename)) { $normalizedPath = $filename; } } return $normalizedPath && is_readable($normalizedPath) ? file($normalizedPath) : null; }
php
private function getExampleFileContents($filename) { $normalizedPath = null; foreach ($this->exampleDirectories as $directory) { $exampleFileFromConfig = $this->constructExamplePath($directory, $filename); if (is_readable($exampleFileFromConfig)) { $normalizedPath = $exampleFileFromConfig; break; } } if (! $normalizedPath) { if (is_readable($this->getExamplePathFromSource($filename))) { $normalizedPath = $this->getExamplePathFromSource($filename); } elseif (is_readable($this->getExamplePathFromExampleDirectory($filename))) { $normalizedPath = $this->getExamplePathFromExampleDirectory($filename); } elseif (is_readable($filename)) { $normalizedPath = $filename; } } return $normalizedPath && is_readable($normalizedPath) ? file($normalizedPath) : null; }
[ "private", "function", "getExampleFileContents", "(", "$", "filename", ")", "{", "$", "normalizedPath", "=", "null", ";", "foreach", "(", "$", "this", "->", "exampleDirectories", "as", "$", "directory", ")", "{", "$", "exampleFileFromConfig", "=", "$", "this", "->", "constructExamplePath", "(", "$", "directory", ",", "$", "filename", ")", ";", "if", "(", "is_readable", "(", "$", "exampleFileFromConfig", ")", ")", "{", "$", "normalizedPath", "=", "$", "exampleFileFromConfig", ";", "break", ";", "}", "}", "if", "(", "!", "$", "normalizedPath", ")", "{", "if", "(", "is_readable", "(", "$", "this", "->", "getExamplePathFromSource", "(", "$", "filename", ")", ")", ")", "{", "$", "normalizedPath", "=", "$", "this", "->", "getExamplePathFromSource", "(", "$", "filename", ")", ";", "}", "elseif", "(", "is_readable", "(", "$", "this", "->", "getExamplePathFromExampleDirectory", "(", "$", "filename", ")", ")", ")", "{", "$", "normalizedPath", "=", "$", "this", "->", "getExamplePathFromExampleDirectory", "(", "$", "filename", ")", ";", "}", "elseif", "(", "is_readable", "(", "$", "filename", ")", ")", "{", "$", "normalizedPath", "=", "$", "filename", ";", "}", "}", "return", "$", "normalizedPath", "&&", "is_readable", "(", "$", "normalizedPath", ")", "?", "file", "(", "$", "normalizedPath", ")", ":", "null", ";", "}" ]
Attempts to find the requested example file and returns its contents or null if no file was found. This method will try several methods in search of the given example file, the first one it encounters is returned: 1. Iterates through all examples folders for the given filename 2. Checks the source folder for the given filename 3. Checks the 'examples' folder in the current working directory for examples 4. Checks the path relative to the current working directory for the given filename @param string $filename @return string|null
[ "Attempts", "to", "find", "the", "requested", "example", "file", "and", "returns", "its", "contents", "or", "null", "if", "no", "file", "was", "found", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Example/Finder.php#L103-L126
23,408
novaway/open-graph
src/Metadata/ClassMetadata.php
ClassMetadata.addGraphMetadata
public function addGraphMetadata(GraphNode $node, GraphMetadataInterface $data) { $this->nodes[] = [ 'node' => $node, 'object' => $data, ]; return $this; }
php
public function addGraphMetadata(GraphNode $node, GraphMetadataInterface $data) { $this->nodes[] = [ 'node' => $node, 'object' => $data, ]; return $this; }
[ "public", "function", "addGraphMetadata", "(", "GraphNode", "$", "node", ",", "GraphMetadataInterface", "$", "data", ")", "{", "$", "this", "->", "nodes", "[", "]", "=", "[", "'node'", "=>", "$", "node", ",", "'object'", "=>", "$", "data", ",", "]", ";", "return", "$", "this", ";", "}" ]
Add OpenGraph metadata @param GraphNode $type @param GraphMetadataInterface $data @return ClassMetadata
[ "Add", "OpenGraph", "metadata" ]
19817bee4b91cf26ca3fe44883ad58b32328e464
https://github.com/novaway/open-graph/blob/19817bee4b91cf26ca3fe44883ad58b32328e464/src/Metadata/ClassMetadata.php#L51-L59
23,409
shtrihstr/simple-rest-api
src/Router.php
Router.match
public function match( $method, $path, callable $callback ) { $route = new Route( mb_strtoupper( $method ), $path, $callback ); $this->_routes[] = $route; return $route; }
php
public function match( $method, $path, callable $callback ) { $route = new Route( mb_strtoupper( $method ), $path, $callback ); $this->_routes[] = $route; return $route; }
[ "public", "function", "match", "(", "$", "method", ",", "$", "path", ",", "callable", "$", "callback", ")", "{", "$", "route", "=", "new", "Route", "(", "mb_strtoupper", "(", "$", "method", ")", ",", "$", "path", ",", "$", "callback", ")", ";", "$", "this", "->", "_routes", "[", "]", "=", "$", "route", ";", "return", "$", "route", ";", "}" ]
Maps a request to a callable. @param string $method Request method @param string $path Matched route path @param callable $callback Callback that returns the response when matched @return Route
[ "Maps", "a", "request", "to", "a", "callable", "." ]
e59c87a604065525729486de3081d4a44aa2468e
https://github.com/shtrihstr/simple-rest-api/blob/e59c87a604065525729486de3081d4a44aa2468e/src/Router.php#L111-L115
23,410
infinity-next/sleuth
src/Traits/DetectiveTrait.php
DetectiveTrait.check
public function check($file, $verify = null) { if ($this->prepareFile($file)) { $leads = $this->leads(); if (!is_null($verify)) { if (isset($leads[$verify])) { return $this->checkLead($leads[$verify]); } return false; } else { foreach ($leads as $lead) { $results = $this->checkLead($lead); // We're sure we've found something. if ($results === true) { return true; } // We're sure this detective can find nothing. else if ($results === false) { break; } } } } return false; }
php
public function check($file, $verify = null) { if ($this->prepareFile($file)) { $leads = $this->leads(); if (!is_null($verify)) { if (isset($leads[$verify])) { return $this->checkLead($leads[$verify]); } return false; } else { foreach ($leads as $lead) { $results = $this->checkLead($lead); // We're sure we've found something. if ($results === true) { return true; } // We're sure this detective can find nothing. else if ($results === false) { break; } } } } return false; }
[ "public", "function", "check", "(", "$", "file", ",", "$", "verify", "=", "null", ")", "{", "if", "(", "$", "this", "->", "prepareFile", "(", "$", "file", ")", ")", "{", "$", "leads", "=", "$", "this", "->", "leads", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "verify", ")", ")", "{", "if", "(", "isset", "(", "$", "leads", "[", "$", "verify", "]", ")", ")", "{", "return", "$", "this", "->", "checkLead", "(", "$", "leads", "[", "$", "verify", "]", ")", ";", "}", "return", "false", ";", "}", "else", "{", "foreach", "(", "$", "leads", "as", "$", "lead", ")", "{", "$", "results", "=", "$", "this", "->", "checkLead", "(", "$", "lead", ")", ";", "// We're sure we've found something.\r", "if", "(", "$", "results", "===", "true", ")", "{", "return", "true", ";", "}", "// We're sure this detective can find nothing.\r", "else", "if", "(", "$", "results", "===", "false", ")", "{", "break", ";", "}", "}", "}", "}", "return", "false", ";", "}" ]
Check the the file against our leads. @param mixed $file File to check. @param string|null $verify Extension to verify against. Checks all possible if unset. @return boolean True if we solved the case, false if not.
[ "Check", "the", "the", "file", "against", "our", "leads", "." ]
924b82e4d60f042fddd6b093b324cfa4bb885a13
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Traits/DetectiveTrait.php#L63-L99
23,411
infinity-next/sleuth
src/Traits/DetectiveTrait.php
DetectiveTrait.closeCase
protected function closeCase($ext, $mime, array $meta = array()) { $this->caseClosed = true; $this->extension = $ext; $this->mime = $mime; $this->metadata = $meta; return true; }
php
protected function closeCase($ext, $mime, array $meta = array()) { $this->caseClosed = true; $this->extension = $ext; $this->mime = $mime; $this->metadata = $meta; return true; }
[ "protected", "function", "closeCase", "(", "$", "ext", ",", "$", "mime", ",", "array", "$", "meta", "=", "array", "(", ")", ")", "{", "$", "this", "->", "caseClosed", "=", "true", ";", "$", "this", "->", "extension", "=", "$", "ext", ";", "$", "this", "->", "mime", "=", "$", "mime", ";", "$", "this", "->", "metadata", "=", "$", "meta", ";", "return", "true", ";", "}" ]
Closes the case by setting protected properties. @param string $ext File extension. @param string $mime Mime type. @param array $meta Meta data, optional. Must be array. @return boolean
[ "Closes", "the", "case", "by", "setting", "protected", "properties", "." ]
924b82e4d60f042fddd6b093b324cfa4bb885a13
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Traits/DetectiveTrait.php#L120-L127
23,412
infinity-next/sleuth
src/Traits/DetectiveTrait.php
DetectiveTrait.leads
protected function leads() { // Pull a list of methods that have the leadEXT syntax. $leads = preg_grep('/^lead(?<ext>[A-Z0-9]+)$/', get_class_methods($this)); // Organize them as an array where keys and values are the same thing. $leads = array_combine($leads, $leads); // Try to find an extension method from our file. $ext = "lead" . strtoupper(pathinfo($this->file, PATHINFO_EXTENSION)); // If that method exists, // bring it to the front of the array so that it is checked first. if (isset($leads[$ext])) { $newLeads = [ $ext => $leads[$ext] ]; unset($leads[$ext]); $newLeads += $leads; $leads = $newLeads; unset($newleads); } return $leads; }
php
protected function leads() { // Pull a list of methods that have the leadEXT syntax. $leads = preg_grep('/^lead(?<ext>[A-Z0-9]+)$/', get_class_methods($this)); // Organize them as an array where keys and values are the same thing. $leads = array_combine($leads, $leads); // Try to find an extension method from our file. $ext = "lead" . strtoupper(pathinfo($this->file, PATHINFO_EXTENSION)); // If that method exists, // bring it to the front of the array so that it is checked first. if (isset($leads[$ext])) { $newLeads = [ $ext => $leads[$ext] ]; unset($leads[$ext]); $newLeads += $leads; $leads = $newLeads; unset($newleads); } return $leads; }
[ "protected", "function", "leads", "(", ")", "{", "// Pull a list of methods that have the leadEXT syntax.\r", "$", "leads", "=", "preg_grep", "(", "'/^lead(?<ext>[A-Z0-9]+)$/'", ",", "get_class_methods", "(", "$", "this", ")", ")", ";", "// Organize them as an array where keys and values are the same thing.\r", "$", "leads", "=", "array_combine", "(", "$", "leads", ",", "$", "leads", ")", ";", "// Try to find an extension method from our file.\r", "$", "ext", "=", "\"lead\"", ".", "strtoupper", "(", "pathinfo", "(", "$", "this", "->", "file", ",", "PATHINFO_EXTENSION", ")", ")", ";", "// If that method exists,\r", "// bring it to the front of the array so that it is checked first.\r", "if", "(", "isset", "(", "$", "leads", "[", "$", "ext", "]", ")", ")", "{", "$", "newLeads", "=", "[", "$", "ext", "=>", "$", "leads", "[", "$", "ext", "]", "]", ";", "unset", "(", "$", "leads", "[", "$", "ext", "]", ")", ";", "$", "newLeads", "+=", "$", "leads", ";", "$", "leads", "=", "$", "newLeads", ";", "unset", "(", "$", "newleads", ")", ";", "}", "return", "$", "leads", ";", "}" ]
Returns an array of file extensions this detective has leads on. @return array Of file extensions.
[ "Returns", "an", "array", "of", "file", "extensions", "this", "detective", "has", "leads", "on", "." ]
924b82e4d60f042fddd6b093b324cfa4bb885a13
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Traits/DetectiveTrait.php#L229-L250
23,413
FrenzelGmbH/cm-address
controllers/base/CountryController.php
CountryController.actionCreate
public function actionCreate() { $model = new Country; try { if ($model->load($_POST) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } elseif (!\Yii::$app->request->isPost) { $model->load($_GET); } } catch (\Exception $e) { $msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage(); $model->addError('_exception', $msg); } return $this->render('create', ['model' => $model]); }
php
public function actionCreate() { $model = new Country; try { if ($model->load($_POST) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } elseif (!\Yii::$app->request->isPost) { $model->load($_GET); } } catch (\Exception $e) { $msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage(); $model->addError('_exception', $msg); } return $this->render('create', ['model' => $model]); }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "model", "=", "new", "Country", ";", "try", "{", "if", "(", "$", "model", "->", "load", "(", "$", "_POST", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "[", "'view'", ",", "'id'", "=>", "$", "model", "->", "id", "]", ")", ";", "}", "elseif", "(", "!", "\\", "Yii", "::", "$", "app", "->", "request", "->", "isPost", ")", "{", "$", "model", "->", "load", "(", "$", "_GET", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "msg", "=", "(", "isset", "(", "$", "e", "->", "errorInfo", "[", "2", "]", ")", ")", "?", "$", "e", "->", "errorInfo", "[", "2", "]", ":", "$", "e", "->", "getMessage", "(", ")", ";", "$", "model", "->", "addError", "(", "'_exception'", ",", "$", "msg", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'create'", ",", "[", "'model'", "=>", "$", "model", "]", ")", ";", "}" ]
Creates a new Country model. If creation is successful, the browser will be redirected to the 'view' page. @return mixed
[ "Creates", "a", "new", "Country", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
4295671dc603beed4bea6c5a7f77dac9846127f3
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/base/CountryController.php#L71-L86
23,414
FrenzelGmbH/cm-address
controllers/base/CountryController.php
CountryController.actionUpdate
public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load($_POST) && $model->save()) { return $this->redirect(Url::previous()); } else { return $this->render('update', [ 'model' => $model, ]); } }
php
public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load($_POST) && $model->save()) { return $this->redirect(Url::previous()); } else { return $this->render('update', [ 'model' => $model, ]); } }
[ "public", "function", "actionUpdate", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "if", "(", "$", "model", "->", "load", "(", "$", "_POST", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "Url", "::", "previous", "(", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "render", "(", "'update'", ",", "[", "'model'", "=>", "$", "model", ",", "]", ")", ";", "}", "}" ]
Updates an existing Country model. If update is successful, the browser will be redirected to the 'view' page. @param integer $id @return mixed
[ "Updates", "an", "existing", "Country", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
4295671dc603beed4bea6c5a7f77dac9846127f3
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/base/CountryController.php#L94-L105
23,415
FrenzelGmbH/cm-address
controllers/base/CountryController.php
CountryController.actionDelete
public function actionDelete($id) { try { $this->findModel($id)->delete(); } catch (\Exception $e) { $msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage(); \Yii::$app->getSession()->addFlash('error', $msg); return $this->redirect(Url::previous()); } // TODO: improve detection $isPivot = strstr('$id',','); if ($isPivot == true) { return $this->redirect(Url::previous()); } elseif (isset(\Yii::$app->session['__crudReturnUrl']) && \Yii::$app->session['__crudReturnUrl'] != '/') { Url::remember(null); $url = \Yii::$app->session['__crudReturnUrl']; \Yii::$app->session['__crudReturnUrl'] = null; return $this->redirect($url); } else { return $this->redirect(['index']); } }
php
public function actionDelete($id) { try { $this->findModel($id)->delete(); } catch (\Exception $e) { $msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage(); \Yii::$app->getSession()->addFlash('error', $msg); return $this->redirect(Url::previous()); } // TODO: improve detection $isPivot = strstr('$id',','); if ($isPivot == true) { return $this->redirect(Url::previous()); } elseif (isset(\Yii::$app->session['__crudReturnUrl']) && \Yii::$app->session['__crudReturnUrl'] != '/') { Url::remember(null); $url = \Yii::$app->session['__crudReturnUrl']; \Yii::$app->session['__crudReturnUrl'] = null; return $this->redirect($url); } else { return $this->redirect(['index']); } }
[ "public", "function", "actionDelete", "(", "$", "id", ")", "{", "try", "{", "$", "this", "->", "findModel", "(", "$", "id", ")", "->", "delete", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "msg", "=", "(", "isset", "(", "$", "e", "->", "errorInfo", "[", "2", "]", ")", ")", "?", "$", "e", "->", "errorInfo", "[", "2", "]", ":", "$", "e", "->", "getMessage", "(", ")", ";", "\\", "Yii", "::", "$", "app", "->", "getSession", "(", ")", "->", "addFlash", "(", "'error'", ",", "$", "msg", ")", ";", "return", "$", "this", "->", "redirect", "(", "Url", "::", "previous", "(", ")", ")", ";", "}", "// TODO: improve detection", "$", "isPivot", "=", "strstr", "(", "'$id'", ",", "','", ")", ";", "if", "(", "$", "isPivot", "==", "true", ")", "{", "return", "$", "this", "->", "redirect", "(", "Url", "::", "previous", "(", ")", ")", ";", "}", "elseif", "(", "isset", "(", "\\", "Yii", "::", "$", "app", "->", "session", "[", "'__crudReturnUrl'", "]", ")", "&&", "\\", "Yii", "::", "$", "app", "->", "session", "[", "'__crudReturnUrl'", "]", "!=", "'/'", ")", "{", "Url", "::", "remember", "(", "null", ")", ";", "$", "url", "=", "\\", "Yii", "::", "$", "app", "->", "session", "[", "'__crudReturnUrl'", "]", ";", "\\", "Yii", "::", "$", "app", "->", "session", "[", "'__crudReturnUrl'", "]", "=", "null", ";", "return", "$", "this", "->", "redirect", "(", "$", "url", ")", ";", "}", "else", "{", "return", "$", "this", "->", "redirect", "(", "[", "'index'", "]", ")", ";", "}", "}" ]
Deletes an existing Country model. If deletion is successful, the browser will be redirected to the 'index' page. @param integer $id @return mixed
[ "Deletes", "an", "existing", "Country", "model", ".", "If", "deletion", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "index", "page", "." ]
4295671dc603beed4bea6c5a7f77dac9846127f3
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/base/CountryController.php#L113-L136
23,416
chippyash/Assembly-Builder
src/chippyash/Assembler/Assembler.php
Assembler.create
public static function create(array $params = []) { $assembler = new static(); if (!empty($params)) { array_walk($params, function($v, $k) use ($assembler) { $assembler->$k(function() use($v) {return $v;}); }); $assembler->assemble(); } return $assembler; }
php
public static function create(array $params = []) { $assembler = new static(); if (!empty($params)) { array_walk($params, function($v, $k) use ($assembler) { $assembler->$k(function() use($v) {return $v;}); }); $assembler->assemble(); } return $assembler; }
[ "public", "static", "function", "create", "(", "array", "$", "params", "=", "[", "]", ")", "{", "$", "assembler", "=", "new", "static", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "params", ")", ")", "{", "array_walk", "(", "$", "params", ",", "function", "(", "$", "v", ",", "$", "k", ")", "use", "(", "$", "assembler", ")", "{", "$", "assembler", "->", "$", "k", "(", "function", "(", ")", "use", "(", "$", "v", ")", "{", "return", "$", "v", ";", "}", ")", ";", "}", ")", ";", "$", "assembler", "->", "assemble", "(", ")", ";", "}", "return", "$", "assembler", ";", "}" ]
Static Assembler constructor Returns a new Assembler @param array $params Immutable parameters to send into the assembler @return static
[ "Static", "Assembler", "constructor", "Returns", "a", "new", "Assembler" ]
be477306b7a1c09b48ce9e100f9f6680035d0df3
https://github.com/chippyash/Assembly-Builder/blob/be477306b7a1c09b48ce9e100f9f6680035d0df3/src/chippyash/Assembler/Assembler.php#L48-L59
23,417
chippyash/Assembly-Builder
src/chippyash/Assembler/Assembler.php
Assembler.get
public static function get(array $params = []) { if (empty(self::$singleton)) { self::$singleton = static::create($params); } return self::$singleton; }
php
public static function get(array $params = []) { if (empty(self::$singleton)) { self::$singleton = static::create($params); } return self::$singleton; }
[ "public", "static", "function", "get", "(", "array", "$", "params", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "singleton", ")", ")", "{", "self", "::", "$", "singleton", "=", "static", "::", "create", "(", "$", "params", ")", ";", "}", "return", "self", "::", "$", "singleton", ";", "}" ]
Return Singleton instance of Assembler @param array $params Immutable parameters to send into the assembler @return Assembler
[ "Return", "Singleton", "instance", "of", "Assembler" ]
be477306b7a1c09b48ce9e100f9f6680035d0df3
https://github.com/chippyash/Assembly-Builder/blob/be477306b7a1c09b48ce9e100f9f6680035d0df3/src/chippyash/Assembler/Assembler.php#L68-L75
23,418
chippyash/Assembly-Builder
src/chippyash/Assembler/Assembler.php
Assembler.assemble
public function assemble() { foreach ($this->placeHolders as $name => $placeholder) { if (!isset($this->values[$name])) { $this->values[$name] = $this->addVars($placeholder); } } return $this; }
php
public function assemble() { foreach ($this->placeHolders as $name => $placeholder) { if (!isset($this->values[$name])) { $this->values[$name] = $this->addVars($placeholder); } } return $this; }
[ "public", "function", "assemble", "(", ")", "{", "foreach", "(", "$", "this", "->", "placeHolders", "as", "$", "name", "=>", "$", "placeholder", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "values", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "values", "[", "$", "name", "]", "=", "$", "this", "->", "addVars", "(", "$", "placeholder", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Run the Assembly not returning any value. Assembly will not overwrite anything already assembled @return $this
[ "Run", "the", "Assembly", "not", "returning", "any", "value", ".", "Assembly", "will", "not", "overwrite", "anything", "already", "assembled" ]
be477306b7a1c09b48ce9e100f9f6680035d0df3
https://github.com/chippyash/Assembly-Builder/blob/be477306b7a1c09b48ce9e100f9f6680035d0df3/src/chippyash/Assembler/Assembler.php#L129-L138
23,419
chippyash/Assembly-Builder
src/chippyash/Assembler/Assembler.php
Assembler.merge
public function merge(Assembler $other) { //N.B. reflection used so as to not expose values //via some public method $refl = new \ReflectionObject($other); $reflValues = $refl->getProperty('values'); $reflValues->setAccessible(true); $oValues = $reflValues->getValue($other); if (count($oValues) == 0) { return $this; } $this->values = array_merge($this->values, $oValues); return $this; }
php
public function merge(Assembler $other) { //N.B. reflection used so as to not expose values //via some public method $refl = new \ReflectionObject($other); $reflValues = $refl->getProperty('values'); $reflValues->setAccessible(true); $oValues = $reflValues->getValue($other); if (count($oValues) == 0) { return $this; } $this->values = array_merge($this->values, $oValues); return $this; }
[ "public", "function", "merge", "(", "Assembler", "$", "other", ")", "{", "//N.B. reflection used so as to not expose values", "//via some public method", "$", "refl", "=", "new", "\\", "ReflectionObject", "(", "$", "other", ")", ";", "$", "reflValues", "=", "$", "refl", "->", "getProperty", "(", "'values'", ")", ";", "$", "reflValues", "->", "setAccessible", "(", "true", ")", ";", "$", "oValues", "=", "$", "reflValues", "->", "getValue", "(", "$", "other", ")", ";", "if", "(", "count", "(", "$", "oValues", ")", "==", "0", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "values", "=", "array_merge", "(", "$", "this", "->", "values", ",", "$", "oValues", ")", ";", "return", "$", "this", ";", "}" ]
Merge this assembly with another. Obeys the rules of array_merge @param Assembler $other @return $this
[ "Merge", "this", "assembly", "with", "another", ".", "Obeys", "the", "rules", "of", "array_merge" ]
be477306b7a1c09b48ce9e100f9f6680035d0df3
https://github.com/chippyash/Assembly-Builder/blob/be477306b7a1c09b48ce9e100f9f6680035d0df3/src/chippyash/Assembler/Assembler.php#L148-L163
23,420
chippyash/Assembly-Builder
src/chippyash/Assembler/Assembler.php
Assembler.addVars
protected function addVars(\Closure $func) { $args = (new \ReflectionFunction($func))->getParameters(); if (count($args) === 0) { return $func(); } $fArgs = array_map(function($key) { return $this->values[$key]; }, array_map(function($arg) { return $arg->getName(); }, $args ) ); return call_user_func_array($func, $fArgs); }
php
protected function addVars(\Closure $func) { $args = (new \ReflectionFunction($func))->getParameters(); if (count($args) === 0) { return $func(); } $fArgs = array_map(function($key) { return $this->values[$key]; }, array_map(function($arg) { return $arg->getName(); }, $args ) ); return call_user_func_array($func, $fArgs); }
[ "protected", "function", "addVars", "(", "\\", "Closure", "$", "func", ")", "{", "$", "args", "=", "(", "new", "\\", "ReflectionFunction", "(", "$", "func", ")", ")", "->", "getParameters", "(", ")", ";", "if", "(", "count", "(", "$", "args", ")", "===", "0", ")", "{", "return", "$", "func", "(", ")", ";", "}", "$", "fArgs", "=", "array_map", "(", "function", "(", "$", "key", ")", "{", "return", "$", "this", "->", "values", "[", "$", "key", "]", ";", "}", ",", "array_map", "(", "function", "(", "$", "arg", ")", "{", "return", "$", "arg", "->", "getName", "(", ")", ";", "}", ",", "$", "args", ")", ")", ";", "return", "call_user_func_array", "(", "$", "func", ",", "$", "fArgs", ")", ";", "}" ]
Execute the function assigned to the value, binding in values created earlier in the assembly @param \Closure $func @return mixed
[ "Execute", "the", "function", "assigned", "to", "the", "value", "binding", "in", "values", "created", "earlier", "in", "the", "assembly" ]
be477306b7a1c09b48ce9e100f9f6680035d0df3
https://github.com/chippyash/Assembly-Builder/blob/be477306b7a1c09b48ce9e100f9f6680035d0df3/src/chippyash/Assembler/Assembler.php#L173-L191
23,421
infinity-next/sleuth
src/Detectives/svgDetective.php
svgDetective.leadSVG
protected function leadSVG() { // Create a new sanitizer instance $sanitizer = new Sanitizer(); // Load the dirty svg $dirtySVG = file_get_contents($this->file); // Pass it to the sanitizer and get it back clean $cleanSVG = $sanitizer->sanitize($dirtySVG); if (is_string($cleanSVG)) { return $this->closeCase("svg", "image/svg+xml"); } return false; }
php
protected function leadSVG() { // Create a new sanitizer instance $sanitizer = new Sanitizer(); // Load the dirty svg $dirtySVG = file_get_contents($this->file); // Pass it to the sanitizer and get it back clean $cleanSVG = $sanitizer->sanitize($dirtySVG); if (is_string($cleanSVG)) { return $this->closeCase("svg", "image/svg+xml"); } return false; }
[ "protected", "function", "leadSVG", "(", ")", "{", "// Create a new sanitizer instance\r", "$", "sanitizer", "=", "new", "Sanitizer", "(", ")", ";", "// Load the dirty svg\r", "$", "dirtySVG", "=", "file_get_contents", "(", "$", "this", "->", "file", ")", ";", "// Pass it to the sanitizer and get it back clean\r", "$", "cleanSVG", "=", "$", "sanitizer", "->", "sanitize", "(", "$", "dirtySVG", ")", ";", "if", "(", "is_string", "(", "$", "cleanSVG", ")", ")", "{", "return", "$", "this", "->", "closeCase", "(", "\"svg\"", ",", "\"image/svg+xml\"", ")", ";", "}", "return", "false", ";", "}" ]
Checks if thise file is a valid SVG. @return boolean|null
[ "Checks", "if", "thise", "file", "is", "a", "valid", "SVG", "." ]
924b82e4d60f042fddd6b093b324cfa4bb885a13
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/svgDetective.php#L16-L33
23,422
brianium/nomnom
src/Nomnom/UnitResolver.php
UnitResolver.resolve
public static function resolve($key) { if ($key == 'B') return 0; $dict = static::$metric; if (preg_match(static::IEC_PATTERN, $key)) $dict = static::$binary; if (array_key_exists($key, $dict)) return $dict[$key]; throw new UnitNotFoundException(sprintf('Unit "%s" not found', $key)); }
php
public static function resolve($key) { if ($key == 'B') return 0; $dict = static::$metric; if (preg_match(static::IEC_PATTERN, $key)) $dict = static::$binary; if (array_key_exists($key, $dict)) return $dict[$key]; throw new UnitNotFoundException(sprintf('Unit "%s" not found', $key)); }
[ "public", "static", "function", "resolve", "(", "$", "key", ")", "{", "if", "(", "$", "key", "==", "'B'", ")", "return", "0", ";", "$", "dict", "=", "static", "::", "$", "metric", ";", "if", "(", "preg_match", "(", "static", "::", "IEC_PATTERN", ",", "$", "key", ")", ")", "$", "dict", "=", "static", "::", "$", "binary", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "dict", ")", ")", "return", "$", "dict", "[", "$", "key", "]", ";", "throw", "new", "UnitNotFoundException", "(", "sprintf", "(", "'Unit \"%s\" not found'", ",", "$", "key", ")", ")", ";", "}" ]
Lookup the exponent based on prefix @param $key @throws UnitNotFoundException @return int
[ "Lookup", "the", "exponent", "based", "on", "prefix" ]
012e3a6ad17fe2393b6a9db1a4b14c91ab91adcd
https://github.com/brianium/nomnom/blob/012e3a6ad17fe2393b6a9db1a4b14c91ab91adcd/src/Nomnom/UnitResolver.php#L57-L65
23,423
brianium/nomnom
src/Nomnom/UnitResolver.php
UnitResolver.unitsAreDifferent
public static function unitsAreDifferent($first, $second) { return (preg_match(UnitResolver::SI_PATTERN, $first) && preg_match(UnitResolver::IEC_PATTERN, $second)) || (preg_match(UnitResolver::IEC_PATTERN, $first) && preg_match(UnitResolver::SI_PATTERN, $second)); }
php
public static function unitsAreDifferent($first, $second) { return (preg_match(UnitResolver::SI_PATTERN, $first) && preg_match(UnitResolver::IEC_PATTERN, $second)) || (preg_match(UnitResolver::IEC_PATTERN, $first) && preg_match(UnitResolver::SI_PATTERN, $second)); }
[ "public", "static", "function", "unitsAreDifferent", "(", "$", "first", ",", "$", "second", ")", "{", "return", "(", "preg_match", "(", "UnitResolver", "::", "SI_PATTERN", ",", "$", "first", ")", "&&", "preg_match", "(", "UnitResolver", "::", "IEC_PATTERN", ",", "$", "second", ")", ")", "||", "(", "preg_match", "(", "UnitResolver", "::", "IEC_PATTERN", ",", "$", "first", ")", "&&", "preg_match", "(", "UnitResolver", "::", "SI_PATTERN", ",", "$", "second", ")", ")", ";", "}" ]
Check if two units are in the same family @param string $first @param string $second @return bool
[ "Check", "if", "two", "units", "are", "in", "the", "same", "family" ]
012e3a6ad17fe2393b6a9db1a4b14c91ab91adcd
https://github.com/brianium/nomnom/blob/012e3a6ad17fe2393b6a9db1a4b14c91ab91adcd/src/Nomnom/UnitResolver.php#L76-L81
23,424
thiagodp/rtti
lib/RTTI.php
RTTI.getAttributes
static function getAttributes( $obj , $visibilityFlags = null , $getterPrefix = 'get' , $useCamelCase = true , $convertInternalObjects = false ) { if ( ! isset( $obj ) ) { return array(); } $flags = null === $visibilityFlags ? self::allFlags() : $visibilityFlags; $attributes = array(); $reflectionObject = new \ReflectionObject( $obj ); $currentClass = new \ReflectionClass( $obj ); while ( $currentClass !== false && ! $currentClass->isInterface() ) { $properties = $currentClass->getProperties( $flags ); foreach ( $properties as $property ) { $attributeName = $property->getName(); $methodName = $getterPrefix . ( $useCamelCase ? self::mb_ucfirst( $attributeName ) : $attributeName ); if ( $property->isPrivate() || $property->isProtected() ) { if ( $reflectionObject->hasMethod( $methodName ) ) { $method = $reflectionObject->getMethod( $methodName ); if ( $method->isPublic() ) { $attributes[ $attributeName ] = $method->invoke( $obj ); } } else { // maybe has a __call magic method $attributes[ $attributeName ] = $obj->{ $methodName }(); } } else { // public method try { $attributes[ $attributeName ] = $obj->{ $attributeName }; } catch ( \Exception $e ) { // Ignore } } } // No properties? -> try to retrieve public properties if ( count( $properties ) < 1 ) { $properties = get_object_vars( $obj ); foreach ( $properties as $k => $v ) { $attributes[ $k ] = $v; } } $currentClass = $currentClass->getParentClass(); } if ( $convertInternalObjects ) { // Analyse all internal objects foreach ( $attributes as $key => $value ) { if ( is_object( $value ) ) { $attributes[ $key ] = self::getAttributes( $value, $flags, $getterPrefix, $useCamelCase ); } } } return $attributes; }
php
static function getAttributes( $obj , $visibilityFlags = null , $getterPrefix = 'get' , $useCamelCase = true , $convertInternalObjects = false ) { if ( ! isset( $obj ) ) { return array(); } $flags = null === $visibilityFlags ? self::allFlags() : $visibilityFlags; $attributes = array(); $reflectionObject = new \ReflectionObject( $obj ); $currentClass = new \ReflectionClass( $obj ); while ( $currentClass !== false && ! $currentClass->isInterface() ) { $properties = $currentClass->getProperties( $flags ); foreach ( $properties as $property ) { $attributeName = $property->getName(); $methodName = $getterPrefix . ( $useCamelCase ? self::mb_ucfirst( $attributeName ) : $attributeName ); if ( $property->isPrivate() || $property->isProtected() ) { if ( $reflectionObject->hasMethod( $methodName ) ) { $method = $reflectionObject->getMethod( $methodName ); if ( $method->isPublic() ) { $attributes[ $attributeName ] = $method->invoke( $obj ); } } else { // maybe has a __call magic method $attributes[ $attributeName ] = $obj->{ $methodName }(); } } else { // public method try { $attributes[ $attributeName ] = $obj->{ $attributeName }; } catch ( \Exception $e ) { // Ignore } } } // No properties? -> try to retrieve public properties if ( count( $properties ) < 1 ) { $properties = get_object_vars( $obj ); foreach ( $properties as $k => $v ) { $attributes[ $k ] = $v; } } $currentClass = $currentClass->getParentClass(); } if ( $convertInternalObjects ) { // Analyse all internal objects foreach ( $attributes as $key => $value ) { if ( is_object( $value ) ) { $attributes[ $key ] = self::getAttributes( $value, $flags, $getterPrefix, $useCamelCase ); } } } return $attributes; }
[ "static", "function", "getAttributes", "(", "$", "obj", ",", "$", "visibilityFlags", "=", "null", ",", "$", "getterPrefix", "=", "'get'", ",", "$", "useCamelCase", "=", "true", ",", "$", "convertInternalObjects", "=", "false", ")", "{", "if", "(", "!", "isset", "(", "$", "obj", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "flags", "=", "null", "===", "$", "visibilityFlags", "?", "self", "::", "allFlags", "(", ")", ":", "$", "visibilityFlags", ";", "$", "attributes", "=", "array", "(", ")", ";", "$", "reflectionObject", "=", "new", "\\", "ReflectionObject", "(", "$", "obj", ")", ";", "$", "currentClass", "=", "new", "\\", "ReflectionClass", "(", "$", "obj", ")", ";", "while", "(", "$", "currentClass", "!==", "false", "&&", "!", "$", "currentClass", "->", "isInterface", "(", ")", ")", "{", "$", "properties", "=", "$", "currentClass", "->", "getProperties", "(", "$", "flags", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "attributeName", "=", "$", "property", "->", "getName", "(", ")", ";", "$", "methodName", "=", "$", "getterPrefix", ".", "(", "$", "useCamelCase", "?", "self", "::", "mb_ucfirst", "(", "$", "attributeName", ")", ":", "$", "attributeName", ")", ";", "if", "(", "$", "property", "->", "isPrivate", "(", ")", "||", "$", "property", "->", "isProtected", "(", ")", ")", "{", "if", "(", "$", "reflectionObject", "->", "hasMethod", "(", "$", "methodName", ")", ")", "{", "$", "method", "=", "$", "reflectionObject", "->", "getMethod", "(", "$", "methodName", ")", ";", "if", "(", "$", "method", "->", "isPublic", "(", ")", ")", "{", "$", "attributes", "[", "$", "attributeName", "]", "=", "$", "method", "->", "invoke", "(", "$", "obj", ")", ";", "}", "}", "else", "{", "// maybe has a __call magic method", "$", "attributes", "[", "$", "attributeName", "]", "=", "$", "obj", "->", "{", "$", "methodName", "}", "(", ")", ";", "}", "}", "else", "{", "// public method", "try", "{", "$", "attributes", "[", "$", "attributeName", "]", "=", "$", "obj", "->", "{", "$", "attributeName", "}", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// Ignore", "}", "}", "}", "// No properties? -> try to retrieve public properties", "if", "(", "count", "(", "$", "properties", ")", "<", "1", ")", "{", "$", "properties", "=", "get_object_vars", "(", "$", "obj", ")", ";", "foreach", "(", "$", "properties", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "attributes", "[", "$", "k", "]", "=", "$", "v", ";", "}", "}", "$", "currentClass", "=", "$", "currentClass", "->", "getParentClass", "(", ")", ";", "}", "if", "(", "$", "convertInternalObjects", ")", "{", "// Analyse all internal objects", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "attributes", "[", "$", "key", "]", "=", "self", "::", "getAttributes", "(", "$", "value", ",", "$", "flags", ",", "$", "getterPrefix", ",", "$", "useCamelCase", ")", ";", "}", "}", "}", "return", "$", "attributes", ";", "}" ]
Retrieve names and values from the attributes of a object, as a map. @param object $obj The object. @param int $visibilityFlags Filter visibility flags. Can be added. Example: RTTI::IS_PRIVATE | RTTI::IS_PROTECTED Optional, defaults to RTTI::allFlags(). @param string $getterPrefix The prefix for getter public methods. Default is 'get'. @param bool $useCamelCase If true, private and protected attributes will be accessed by camelCase public methods. Default is true. @param bool $convertInternalObjects If true, converts internal objects. Default is false. @return array @throws ReflectionException
[ "Retrieve", "names", "and", "values", "from", "the", "attributes", "of", "a", "object", "as", "a", "map", "." ]
513056bb2843bbf495a83f8a1481c9aaec120c4b
https://github.com/thiagodp/rtti/blob/513056bb2843bbf495a83f8a1481c9aaec120c4b/lib/RTTI.php#L56-L126
23,425
thiagodp/rtti
lib/RTTI.php
RTTI.getPrivateAttributes
static function getPrivateAttributes( $obj, $getterPrefix = 'get', $useCamelCase = true ) { return self::getAttributes( $obj, self::IS_PRIVATE, $getterPrefix, $useCamelCase ); }
php
static function getPrivateAttributes( $obj, $getterPrefix = 'get', $useCamelCase = true ) { return self::getAttributes( $obj, self::IS_PRIVATE, $getterPrefix, $useCamelCase ); }
[ "static", "function", "getPrivateAttributes", "(", "$", "obj", ",", "$", "getterPrefix", "=", "'get'", ",", "$", "useCamelCase", "=", "true", ")", "{", "return", "self", "::", "getAttributes", "(", "$", "obj", ",", "self", "::", "IS_PRIVATE", ",", "$", "getterPrefix", ",", "$", "useCamelCase", ")", ";", "}" ]
Retrieve names and values from the private attributes of a object, as a map. This method has been kept for backward compatibility. @param object $obj The object. @param string $getterPrefix The prefix for getter public methods (defaults to 'get'). @param bool $useCamelCase If true, private attributes will be accessed by camelCase public methods (default true). @return array
[ "Retrieve", "names", "and", "values", "from", "the", "private", "attributes", "of", "a", "object", "as", "a", "map", ".", "This", "method", "has", "been", "kept", "for", "backward", "compatibility", "." ]
513056bb2843bbf495a83f8a1481c9aaec120c4b
https://github.com/thiagodp/rtti/blob/513056bb2843bbf495a83f8a1481c9aaec120c4b/lib/RTTI.php#L137-L139
23,426
thiagodp/rtti
lib/RTTI.php
RTTI.setAttributes
static function setAttributes( array $map , &$obj , $visibilityFlags = null , $setterPrefix = 'set' , $useCamelCase = true ) { $flags = null === $visibilityFlags ? self::allFlags() : $visibilityFlags; $reflectionObject = new \ReflectionObject( $obj ); $currentClass = new \ReflectionClass( $obj ); while ( $currentClass !== false && ! $currentClass->isInterface() ) { $properties = $currentClass->getProperties( $flags ); foreach ( $properties as $property ) { $attributeName = $property->getName(); $methodName = $setterPrefix . ( $useCamelCase ? self::mb_ucfirst( $attributeName ) : $attributeName ); if ( $property->isPrivate() || $property->isProtected() ) { if ( $reflectionObject->hasMethod( $methodName ) ) { $method = $reflectionObject->getMethod( $methodName ); if ( $method->isPublic() && array_key_exists( $attributeName, $map ) ) { $method->invoke( $obj, $map[ $attributeName ] ); } } } else { // public try { if ( array_key_exists( $attributeName, $map ) ) { $obj->{ $attributeName } = $map[ $attributeName ]; } } catch ( \Exception $e ) { // Ignore } } } // No properties? -> try to retrieve only public properties if ( count( $properties ) < 1 ) { $properties = get_object_vars( $obj ); foreach ( $properties as $attributeName => $v ) { if ( array_key_exists( $attributeName, $map ) ) { try { $obj->{ $attributeName } = $map[ $attributeName ]; } catch ( \Exception $e ) { // Ignore } } } } $currentClass = $currentClass->getParentClass(); } }
php
static function setAttributes( array $map , &$obj , $visibilityFlags = null , $setterPrefix = 'set' , $useCamelCase = true ) { $flags = null === $visibilityFlags ? self::allFlags() : $visibilityFlags; $reflectionObject = new \ReflectionObject( $obj ); $currentClass = new \ReflectionClass( $obj ); while ( $currentClass !== false && ! $currentClass->isInterface() ) { $properties = $currentClass->getProperties( $flags ); foreach ( $properties as $property ) { $attributeName = $property->getName(); $methodName = $setterPrefix . ( $useCamelCase ? self::mb_ucfirst( $attributeName ) : $attributeName ); if ( $property->isPrivate() || $property->isProtected() ) { if ( $reflectionObject->hasMethod( $methodName ) ) { $method = $reflectionObject->getMethod( $methodName ); if ( $method->isPublic() && array_key_exists( $attributeName, $map ) ) { $method->invoke( $obj, $map[ $attributeName ] ); } } } else { // public try { if ( array_key_exists( $attributeName, $map ) ) { $obj->{ $attributeName } = $map[ $attributeName ]; } } catch ( \Exception $e ) { // Ignore } } } // No properties? -> try to retrieve only public properties if ( count( $properties ) < 1 ) { $properties = get_object_vars( $obj ); foreach ( $properties as $attributeName => $v ) { if ( array_key_exists( $attributeName, $map ) ) { try { $obj->{ $attributeName } = $map[ $attributeName ]; } catch ( \Exception $e ) { // Ignore } } } } $currentClass = $currentClass->getParentClass(); } }
[ "static", "function", "setAttributes", "(", "array", "$", "map", ",", "&", "$", "obj", ",", "$", "visibilityFlags", "=", "null", ",", "$", "setterPrefix", "=", "'set'", ",", "$", "useCamelCase", "=", "true", ")", "{", "$", "flags", "=", "null", "===", "$", "visibilityFlags", "?", "self", "::", "allFlags", "(", ")", ":", "$", "visibilityFlags", ";", "$", "reflectionObject", "=", "new", "\\", "ReflectionObject", "(", "$", "obj", ")", ";", "$", "currentClass", "=", "new", "\\", "ReflectionClass", "(", "$", "obj", ")", ";", "while", "(", "$", "currentClass", "!==", "false", "&&", "!", "$", "currentClass", "->", "isInterface", "(", ")", ")", "{", "$", "properties", "=", "$", "currentClass", "->", "getProperties", "(", "$", "flags", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "attributeName", "=", "$", "property", "->", "getName", "(", ")", ";", "$", "methodName", "=", "$", "setterPrefix", ".", "(", "$", "useCamelCase", "?", "self", "::", "mb_ucfirst", "(", "$", "attributeName", ")", ":", "$", "attributeName", ")", ";", "if", "(", "$", "property", "->", "isPrivate", "(", ")", "||", "$", "property", "->", "isProtected", "(", ")", ")", "{", "if", "(", "$", "reflectionObject", "->", "hasMethod", "(", "$", "methodName", ")", ")", "{", "$", "method", "=", "$", "reflectionObject", "->", "getMethod", "(", "$", "methodName", ")", ";", "if", "(", "$", "method", "->", "isPublic", "(", ")", "&&", "array_key_exists", "(", "$", "attributeName", ",", "$", "map", ")", ")", "{", "$", "method", "->", "invoke", "(", "$", "obj", ",", "$", "map", "[", "$", "attributeName", "]", ")", ";", "}", "}", "}", "else", "{", "// public", "try", "{", "if", "(", "array_key_exists", "(", "$", "attributeName", ",", "$", "map", ")", ")", "{", "$", "obj", "->", "{", "$", "attributeName", "}", "=", "$", "map", "[", "$", "attributeName", "]", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// Ignore", "}", "}", "}", "// No properties? -> try to retrieve only public properties", "if", "(", "count", "(", "$", "properties", ")", "<", "1", ")", "{", "$", "properties", "=", "get_object_vars", "(", "$", "obj", ")", ";", "foreach", "(", "$", "properties", "as", "$", "attributeName", "=>", "$", "v", ")", "{", "if", "(", "array_key_exists", "(", "$", "attributeName", ",", "$", "map", ")", ")", "{", "try", "{", "$", "obj", "->", "{", "$", "attributeName", "}", "=", "$", "map", "[", "$", "attributeName", "]", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// Ignore", "}", "}", "}", "}", "$", "currentClass", "=", "$", "currentClass", "->", "getParentClass", "(", ")", ";", "}", "}" ]
Set the attribute values of a object. @param array $map A map with the attribute names and values to be changed. @param object $obj The object to be changed. @param int $visibilityFlags Filter visibility flags. Can be added. Example: RTTI::IS_PRIVATE | RTTI::IS_PROTECTED Optional, defaults to RTTI::allFlags. @param string $setterPrefix The prefix for setter public methods (defaults to 'set'). @param bool $useCamelCase If true, private and protected attributes will be set by camelCase public methods (default true).
[ "Set", "the", "attribute", "values", "of", "a", "object", "." ]
513056bb2843bbf495a83f8a1481c9aaec120c4b
https://github.com/thiagodp/rtti/blob/513056bb2843bbf495a83f8a1481c9aaec120c4b/lib/RTTI.php#L157-L214
23,427
thiagodp/rtti
lib/RTTI.php
RTTI.setPrivateAttributes
static function setPrivateAttributes( array $map, &$obj, $setterPrefix = 'set', $useCamelCase = true ) { self::setAttributes( $map, $obj, \RTTI::IS_PRIVATE, $setterPrefix, $useCamelCase ); }
php
static function setPrivateAttributes( array $map, &$obj, $setterPrefix = 'set', $useCamelCase = true ) { self::setAttributes( $map, $obj, \RTTI::IS_PRIVATE, $setterPrefix, $useCamelCase ); }
[ "static", "function", "setPrivateAttributes", "(", "array", "$", "map", ",", "&", "$", "obj", ",", "$", "setterPrefix", "=", "'set'", ",", "$", "useCamelCase", "=", "true", ")", "{", "self", "::", "setAttributes", "(", "$", "map", ",", "$", "obj", ",", "\\", "RTTI", "::", "IS_PRIVATE", ",", "$", "setterPrefix", ",", "$", "useCamelCase", ")", ";", "}" ]
Set the attribute values of a object. This method has been kept for backward compatibility. @param array $map A map with the attribute names and values to be changed. @param object $obj The object to be changed. @param string $setterPrefix The prefix for setter public methods (defaults to 'set'). @param bool $useCamelCase If true, private and protected attributes will be set by camelCase public methods (default true).
[ "Set", "the", "attribute", "values", "of", "a", "object", ".", "This", "method", "has", "been", "kept", "for", "backward", "compatibility", "." ]
513056bb2843bbf495a83f8a1481c9aaec120c4b
https://github.com/thiagodp/rtti/blob/513056bb2843bbf495a83f8a1481c9aaec120c4b/lib/RTTI.php#L229-L233
23,428
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/File.php
Dwoo_Template_File.getResourceIdentifier
public function getResourceIdentifier() { if ($this->resolvedPath !== null) { return $this->resolvedPath; } elseif ($this->includePath === null) { return $this->file; } else { foreach ($this->includePath as $path) { $path = rtrim($path, DIRECTORY_SEPARATOR); if (file_exists($path.DIRECTORY_SEPARATOR.$this->file) === true) { $this->resolvedPath = $path . DIRECTORY_SEPARATOR . $this->file; return $this->resolvedPath; } } throw new Dwoo_Exception('Template "'.$this->file.'" could not be found in any of your include path(s)'); } }
php
public function getResourceIdentifier() { if ($this->resolvedPath !== null) { return $this->resolvedPath; } elseif ($this->includePath === null) { return $this->file; } else { foreach ($this->includePath as $path) { $path = rtrim($path, DIRECTORY_SEPARATOR); if (file_exists($path.DIRECTORY_SEPARATOR.$this->file) === true) { $this->resolvedPath = $path . DIRECTORY_SEPARATOR . $this->file; return $this->resolvedPath; } } throw new Dwoo_Exception('Template "'.$this->file.'" could not be found in any of your include path(s)'); } }
[ "public", "function", "getResourceIdentifier", "(", ")", "{", "if", "(", "$", "this", "->", "resolvedPath", "!==", "null", ")", "{", "return", "$", "this", "->", "resolvedPath", ";", "}", "elseif", "(", "$", "this", "->", "includePath", "===", "null", ")", "{", "return", "$", "this", "->", "file", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "includePath", "as", "$", "path", ")", "{", "$", "path", "=", "rtrim", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", ";", "if", "(", "file_exists", "(", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "file", ")", "===", "true", ")", "{", "$", "this", "->", "resolvedPath", "=", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "file", ";", "return", "$", "this", "->", "resolvedPath", ";", "}", "}", "throw", "new", "Dwoo_Exception", "(", "'Template \"'", ".", "$", "this", "->", "file", ".", "'\" could not be found in any of your include path(s)'", ")", ";", "}", "}" ]
returns this template's source filename @return string
[ "returns", "this", "template", "s", "source", "filename" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/File.php#L138-L155
23,429
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.read
private function read() { $files = $this->getFilesystem()->allFiles(app_path() . '/database/seeds'); $filtered = []; foreach ($files as $file) { if (strpos(file_get_contents($file->getPathName()), 'extends Seeder') != false) { if ($file->getFileName() != 'DatabaseSeeder.php') { $filtered[] = $file->getFileName(); } } } $this->setFiles($filtered); }
php
private function read() { $files = $this->getFilesystem()->allFiles(app_path() . '/database/seeds'); $filtered = []; foreach ($files as $file) { if (strpos(file_get_contents($file->getPathName()), 'extends Seeder') != false) { if ($file->getFileName() != 'DatabaseSeeder.php') { $filtered[] = $file->getFileName(); } } } $this->setFiles($filtered); }
[ "private", "function", "read", "(", ")", "{", "$", "files", "=", "$", "this", "->", "getFilesystem", "(", ")", "->", "allFiles", "(", "app_path", "(", ")", ".", "'/database/seeds'", ")", ";", "$", "filtered", "=", "[", "]", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "strpos", "(", "file_get_contents", "(", "$", "file", "->", "getPathName", "(", ")", ")", ",", "'extends Seeder'", ")", "!=", "false", ")", "{", "if", "(", "$", "file", "->", "getFileName", "(", ")", "!=", "'DatabaseSeeder.php'", ")", "{", "$", "filtered", "[", "]", "=", "$", "file", "->", "getFileName", "(", ")", ";", "}", "}", "}", "$", "this", "->", "setFiles", "(", "$", "filtered", ")", ";", "}" ]
Get an array of all the files that is actually compatible with the files we're looking for.
[ "Get", "an", "array", "of", "all", "the", "files", "that", "is", "actually", "compatible", "with", "the", "files", "we", "re", "looking", "for", "." ]
165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L147-L165
23,430
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.write
private function write() { $content = ''; foreach ($this->getFiles() as $file) { $content .= '$this->call(\'' . str_replace('.php', '', $file) . '\');'; } $databaseSeeder = str_replace('{calls}', $content, $this->getPattern()); $this->getFilesystem()->put(app_path() . '/database/seeds/DatabaseSeeder.php', $databaseSeeder); }
php
private function write() { $content = ''; foreach ($this->getFiles() as $file) { $content .= '$this->call(\'' . str_replace('.php', '', $file) . '\');'; } $databaseSeeder = str_replace('{calls}', $content, $this->getPattern()); $this->getFilesystem()->put(app_path() . '/database/seeds/DatabaseSeeder.php', $databaseSeeder); }
[ "private", "function", "write", "(", ")", "{", "$", "content", "=", "''", ";", "foreach", "(", "$", "this", "->", "getFiles", "(", ")", "as", "$", "file", ")", "{", "$", "content", ".=", "'$this->call(\\''", ".", "str_replace", "(", "'.php'", ",", "''", ",", "$", "file", ")", ".", "'\\');'", ";", "}", "$", "databaseSeeder", "=", "str_replace", "(", "'{calls}'", ",", "$", "content", ",", "$", "this", "->", "getPattern", "(", ")", ")", ";", "$", "this", "->", "getFilesystem", "(", ")", "->", "put", "(", "app_path", "(", ")", ".", "'/database/seeds/DatabaseSeeder.php'", ",", "$", "databaseSeeder", ")", ";", "}" ]
Write the new DatabaseSeeder.php
[ "Write", "the", "new", "DatabaseSeeder", ".", "php" ]
165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L171-L183
23,431
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.restore
public function restore() { $this->getFilesystem()->put(app_path() . '/database/seeds/DatabaseSeeder.php', $this->getCopied()); $this->getFilesystem()->delete(app_path() . '/database/seeds/DatabaseSeeder.old'); }
php
public function restore() { $this->getFilesystem()->put(app_path() . '/database/seeds/DatabaseSeeder.php', $this->getCopied()); $this->getFilesystem()->delete(app_path() . '/database/seeds/DatabaseSeeder.old'); }
[ "public", "function", "restore", "(", ")", "{", "$", "this", "->", "getFilesystem", "(", ")", "->", "put", "(", "app_path", "(", ")", ".", "'/database/seeds/DatabaseSeeder.php'", ",", "$", "this", "->", "getCopied", "(", ")", ")", ";", "$", "this", "->", "getFilesystem", "(", ")", "->", "delete", "(", "app_path", "(", ")", ".", "'/database/seeds/DatabaseSeeder.old'", ")", ";", "}" ]
Restore the DatabaseSeeder.php file to it's previous version.
[ "Restore", "the", "DatabaseSeeder", ".", "php", "file", "to", "it", "s", "previous", "version", "." ]
165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L189-L194
23,432
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.getList
public function getList($list) { $filteredList = []; foreach (explode(',', $list) as $item) { if ($item != '') { $filteredList[] = $item; } } return $filteredList; }
php
public function getList($list) { $filteredList = []; foreach (explode(',', $list) as $item) { if ($item != '') { $filteredList[] = $item; } } return $filteredList; }
[ "public", "function", "getList", "(", "$", "list", ")", "{", "$", "filteredList", "=", "[", "]", ";", "foreach", "(", "explode", "(", "','", ",", "$", "list", ")", "as", "$", "item", ")", "{", "if", "(", "$", "item", "!=", "''", ")", "{", "$", "filteredList", "[", "]", "=", "$", "item", ";", "}", "}", "return", "$", "filteredList", ";", "}" ]
Recieves the string list entered by the developer, explode it and only return the ones filtered. @param string $list @return array
[ "Recieves", "the", "string", "list", "entered", "by", "the", "developer", "explode", "it", "and", "only", "return", "the", "ones", "filtered", "." ]
165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L221-L234
23,433
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.only
public function only($list) { $this->copy(); $this->readForOnly($list); $this->write(); $this->setSeeded(count($this->getFiles())); return true; }
php
public function only($list) { $this->copy(); $this->readForOnly($list); $this->write(); $this->setSeeded(count($this->getFiles())); return true; }
[ "public", "function", "only", "(", "$", "list", ")", "{", "$", "this", "->", "copy", "(", ")", ";", "$", "this", "->", "readForOnly", "(", "$", "list", ")", ";", "$", "this", "->", "write", "(", ")", ";", "$", "this", "->", "setSeeded", "(", "count", "(", "$", "this", "->", "getFiles", "(", ")", ")", ")", ";", "return", "true", ";", "}" ]
Copy the current DatabaseSeeder.php file, loop through each file and verify it's idententy with ther files array, write the new DatabaseSeeder.php file and return true if it's alright. @param string $list @return boolean
[ "Copy", "the", "current", "DatabaseSeeder", ".", "php", "file", "loop", "through", "each", "file", "and", "verify", "it", "s", "idententy", "with", "ther", "files", "array", "write", "the", "new", "DatabaseSeeder", ".", "php", "file", "and", "return", "true", "if", "it", "s", "alright", "." ]
165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L268-L279
23,434
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.get
public function get($content, array $variables = []) { $replacements = []; $instruction = 'foreach'; foreach ($variables as $key => $values) { $inner = $this->getInnerInstruction($content, $instruction); foreach ($inner as $config) { if (!str_contains($config['cleared'], $key)) { continue; } $replacements[$key] = $inner; } } if (!empty($replacements)) { foreach ($replacements as $key => $value) { foreach ($value as $element) { $inner = $this->renderByTwig($element['cleared'], $variables); $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $element['to_replace']], ['', '', $inner], $content); } } } $content = str_replace(['<p>', '</p>', '<br />'], '', $content); $filled = $this->fill($content); preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); if (!isset($matches[0]) or ! isset($matches[1])) { return $filled; } foreach ($matches[0] as $index => $variable) { $filled = str_replace($variable, '{{ ' . $matches[1][$index] . ' }}', $filled); } return $this->renderByTwig($filled, array_merge($variables, $this->variables)); }
php
public function get($content, array $variables = []) { $replacements = []; $instruction = 'foreach'; foreach ($variables as $key => $values) { $inner = $this->getInnerInstruction($content, $instruction); foreach ($inner as $config) { if (!str_contains($config['cleared'], $key)) { continue; } $replacements[$key] = $inner; } } if (!empty($replacements)) { foreach ($replacements as $key => $value) { foreach ($value as $element) { $inner = $this->renderByTwig($element['cleared'], $variables); $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $element['to_replace']], ['', '', $inner], $content); } } } $content = str_replace(['<p>', '</p>', '<br />'], '', $content); $filled = $this->fill($content); preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); if (!isset($matches[0]) or ! isset($matches[1])) { return $filled; } foreach ($matches[0] as $index => $variable) { $filled = str_replace($variable, '{{ ' . $matches[1][$index] . ' }}', $filled); } return $this->renderByTwig($filled, array_merge($variables, $this->variables)); }
[ "public", "function", "get", "(", "$", "content", ",", "array", "$", "variables", "=", "[", "]", ")", "{", "$", "replacements", "=", "[", "]", ";", "$", "instruction", "=", "'foreach'", ";", "foreach", "(", "$", "variables", "as", "$", "key", "=>", "$", "values", ")", "{", "$", "inner", "=", "$", "this", "->", "getInnerInstruction", "(", "$", "content", ",", "$", "instruction", ")", ";", "foreach", "(", "$", "inner", "as", "$", "config", ")", "{", "if", "(", "!", "str_contains", "(", "$", "config", "[", "'cleared'", "]", ",", "$", "key", ")", ")", "{", "continue", ";", "}", "$", "replacements", "[", "$", "key", "]", "=", "$", "inner", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "replacements", ")", ")", "{", "foreach", "(", "$", "replacements", "as", "$", "key", "=>", "$", "value", ")", "{", "foreach", "(", "$", "value", "as", "$", "element", ")", "{", "$", "inner", "=", "$", "this", "->", "renderByTwig", "(", "$", "element", "[", "'cleared'", "]", ",", "$", "variables", ")", ";", "$", "content", "=", "str_replace", "(", "[", "\"[[{$instruction}]]\"", ",", "\"[[/{$instruction}]]\"", ",", "$", "element", "[", "'to_replace'", "]", "]", ",", "[", "''", ",", "''", ",", "$", "inner", "]", ",", "$", "content", ")", ";", "}", "}", "}", "$", "content", "=", "str_replace", "(", "[", "'<p>'", ",", "'</p>'", ",", "'<br />'", "]", ",", "''", ",", "$", "content", ")", ";", "$", "filled", "=", "$", "this", "->", "fill", "(", "$", "content", ")", ";", "preg_match_all", "(", "'/\\[\\[(.*?)\\]\\]/'", ",", "$", "content", ",", "$", "matches", ")", ";", "if", "(", "!", "isset", "(", "$", "matches", "[", "0", "]", ")", "or", "!", "isset", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "$", "filled", ";", "}", "foreach", "(", "$", "matches", "[", "0", "]", "as", "$", "index", "=>", "$", "variable", ")", "{", "$", "filled", "=", "str_replace", "(", "$", "variable", ",", "'{{ '", ".", "$", "matches", "[", "1", "]", "[", "$", "index", "]", ".", "' }}'", ",", "$", "filled", ")", ";", "}", "return", "$", "this", "->", "renderByTwig", "(", "$", "filled", ",", "array_merge", "(", "$", "variables", ",", "$", "this", "->", "variables", ")", ")", ";", "}" ]
Gets variables filled notification content @param string $content @param array $variables @return String
[ "Gets", "variables", "filled", "notification", "content" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L49-L85
23,435
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.fill
public function fill($content) { if ($this->hasInstructions($content)) { $instructions = $this->getInstructions(); foreach ($instructions as $instruction) { $content = $this->parseInstructions($content, $instruction); } } return $this->fillContent($content); }
php
public function fill($content) { if ($this->hasInstructions($content)) { $instructions = $this->getInstructions(); foreach ($instructions as $instruction) { $content = $this->parseInstructions($content, $instruction); } } return $this->fillContent($content); }
[ "public", "function", "fill", "(", "$", "content", ")", "{", "if", "(", "$", "this", "->", "hasInstructions", "(", "$", "content", ")", ")", "{", "$", "instructions", "=", "$", "this", "->", "getInstructions", "(", ")", ";", "foreach", "(", "$", "instructions", "as", "$", "instruction", ")", "{", "$", "content", "=", "$", "this", "->", "parseInstructions", "(", "$", "content", ",", "$", "instruction", ")", ";", "}", "}", "return", "$", "this", "->", "fillContent", "(", "$", "content", ")", ";", "}" ]
fill notification notification content with variables @param String $content @return String
[ "fill", "notification", "notification", "content", "with", "variables" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L127-L136
23,436
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.hasInstructions
protected function hasInstructions($content) { $instructionKeys = $this->getInstructions(); foreach ($instructionKeys as $instructionKey) { if (str_contains($content, ['[[' . $instructionKey . ']]', '[[/' . $instructionKey . ']]'])) { return true; } } return false; }
php
protected function hasInstructions($content) { $instructionKeys = $this->getInstructions(); foreach ($instructionKeys as $instructionKey) { if (str_contains($content, ['[[' . $instructionKey . ']]', '[[/' . $instructionKey . ']]'])) { return true; } } return false; }
[ "protected", "function", "hasInstructions", "(", "$", "content", ")", "{", "$", "instructionKeys", "=", "$", "this", "->", "getInstructions", "(", ")", ";", "foreach", "(", "$", "instructionKeys", "as", "$", "instructionKey", ")", "{", "if", "(", "str_contains", "(", "$", "content", ",", "[", "'[['", ".", "$", "instructionKey", ".", "']]'", ",", "'[[/'", ".", "$", "instructionKey", ".", "']]'", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
whether notification has instructions @param String $content @return boolean
[ "whether", "notification", "has", "instructions" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L158-L167
23,437
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.parseInstructions
protected function parseInstructions($content, $instruction) { $twig = new Twig_Environment(new Twig_Loader_String()); $sources = $this->getStringsBetween($content, "[[{$instruction}]]", "[[/{$instruction}]]"); foreach ($sources as $source) { $toReplace = $source; $source = $this->clearCondition($source); if ($source === '') { return $content; } $variables = $this->extractVariables($source); $renderParams = []; foreach (array_keys($variables) as $index => $key) { $localVariable = 'var_' . $index; $source = str_replace($key, $localVariable, $source); $renderParams[$localVariable] = $variables[$key]; } $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $toReplace], ['', '', $twig->render($source, $renderParams)], $content); } return $content; }
php
protected function parseInstructions($content, $instruction) { $twig = new Twig_Environment(new Twig_Loader_String()); $sources = $this->getStringsBetween($content, "[[{$instruction}]]", "[[/{$instruction}]]"); foreach ($sources as $source) { $toReplace = $source; $source = $this->clearCondition($source); if ($source === '') { return $content; } $variables = $this->extractVariables($source); $renderParams = []; foreach (array_keys($variables) as $index => $key) { $localVariable = 'var_' . $index; $source = str_replace($key, $localVariable, $source); $renderParams[$localVariable] = $variables[$key]; } $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $toReplace], ['', '', $twig->render($source, $renderParams)], $content); } return $content; }
[ "protected", "function", "parseInstructions", "(", "$", "content", ",", "$", "instruction", ")", "{", "$", "twig", "=", "new", "Twig_Environment", "(", "new", "Twig_Loader_String", "(", ")", ")", ";", "$", "sources", "=", "$", "this", "->", "getStringsBetween", "(", "$", "content", ",", "\"[[{$instruction}]]\"", ",", "\"[[/{$instruction}]]\"", ")", ";", "foreach", "(", "$", "sources", "as", "$", "source", ")", "{", "$", "toReplace", "=", "$", "source", ";", "$", "source", "=", "$", "this", "->", "clearCondition", "(", "$", "source", ")", ";", "if", "(", "$", "source", "===", "''", ")", "{", "return", "$", "content", ";", "}", "$", "variables", "=", "$", "this", "->", "extractVariables", "(", "$", "source", ")", ";", "$", "renderParams", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "variables", ")", "as", "$", "index", "=>", "$", "key", ")", "{", "$", "localVariable", "=", "'var_'", ".", "$", "index", ";", "$", "source", "=", "str_replace", "(", "$", "key", ",", "$", "localVariable", ",", "$", "source", ")", ";", "$", "renderParams", "[", "$", "localVariable", "]", "=", "$", "variables", "[", "$", "key", "]", ";", "}", "$", "content", "=", "str_replace", "(", "[", "\"[[{$instruction}]]\"", ",", "\"[[/{$instruction}]]\"", ",", "$", "toReplace", "]", ",", "[", "''", ",", "''", ",", "$", "twig", "->", "render", "(", "$", "source", ",", "$", "renderParams", ")", "]", ",", "$", "content", ")", ";", "}", "return", "$", "content", ";", "}" ]
parsing instructions in notification content @param String $content @param String $instruction @return String
[ "parsing", "instructions", "in", "notification", "content" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L176-L197
23,438
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.clearCondition
protected function clearCondition($source) { $line = $this->getStringBetween($source, '{%', '%}'); if (strlen($line) > 0) { return str_replace(['&#39;', '&nbsp;'], ["'", ' '], $source); } return $source; }
php
protected function clearCondition($source) { $line = $this->getStringBetween($source, '{%', '%}'); if (strlen($line) > 0) { return str_replace(['&#39;', '&nbsp;'], ["'", ' '], $source); } return $source; }
[ "protected", "function", "clearCondition", "(", "$", "source", ")", "{", "$", "line", "=", "$", "this", "->", "getStringBetween", "(", "$", "source", ",", "'{%'", ",", "'%}'", ")", ";", "if", "(", "strlen", "(", "$", "line", ")", ">", "0", ")", "{", "return", "str_replace", "(", "[", "'&#39;'", ",", "'&nbsp;'", "]", ",", "[", "\"'\"", ",", "' '", "]", ",", "$", "source", ")", ";", "}", "return", "$", "source", ";", "}" ]
clear conditions in notification @param String $source @return String
[ "clear", "conditions", "in", "notification" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L205-L212
23,439
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.getStringsBetween
public function getStringsBetween($string, $start, $end) { $lastPos = 0; $positions = array(); while (($lastPos = strpos($string, $start, $lastPos)) !== false) { $positions[] = $lastPos; $lastPos += strlen($start); } $lastPos = 0; $positionsEnd = array(); while (($lastPos = strpos($string, $end, $lastPos)) !== false) { $positionsEnd[] = $lastPos; $lastPos += strlen($end); } $return = []; foreach ($positions as $index => $position) { $return[] = str_replace([$start, $end], '', substr($string, $position, $positionsEnd[$index] - $position)); } return $return; }
php
public function getStringsBetween($string, $start, $end) { $lastPos = 0; $positions = array(); while (($lastPos = strpos($string, $start, $lastPos)) !== false) { $positions[] = $lastPos; $lastPos += strlen($start); } $lastPos = 0; $positionsEnd = array(); while (($lastPos = strpos($string, $end, $lastPos)) !== false) { $positionsEnd[] = $lastPos; $lastPos += strlen($end); } $return = []; foreach ($positions as $index => $position) { $return[] = str_replace([$start, $end], '', substr($string, $position, $positionsEnd[$index] - $position)); } return $return; }
[ "public", "function", "getStringsBetween", "(", "$", "string", ",", "$", "start", ",", "$", "end", ")", "{", "$", "lastPos", "=", "0", ";", "$", "positions", "=", "array", "(", ")", ";", "while", "(", "(", "$", "lastPos", "=", "strpos", "(", "$", "string", ",", "$", "start", ",", "$", "lastPos", ")", ")", "!==", "false", ")", "{", "$", "positions", "[", "]", "=", "$", "lastPos", ";", "$", "lastPos", "+=", "strlen", "(", "$", "start", ")", ";", "}", "$", "lastPos", "=", "0", ";", "$", "positionsEnd", "=", "array", "(", ")", ";", "while", "(", "(", "$", "lastPos", "=", "strpos", "(", "$", "string", ",", "$", "end", ",", "$", "lastPos", ")", ")", "!==", "false", ")", "{", "$", "positionsEnd", "[", "]", "=", "$", "lastPos", ";", "$", "lastPos", "+=", "strlen", "(", "$", "end", ")", ";", "}", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "positions", "as", "$", "index", "=>", "$", "position", ")", "{", "$", "return", "[", "]", "=", "str_replace", "(", "[", "$", "start", ",", "$", "end", "]", ",", "''", ",", "substr", "(", "$", "string", ",", "$", "position", ",", "$", "positionsEnd", "[", "$", "index", "]", "-", "$", "position", ")", ")", ";", "}", "return", "$", "return", ";", "}" ]
gets list of occurences between two strings @param String $string @param String $start @param String $end @return array
[ "gets", "list", "of", "occurences", "between", "two", "strings" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L222-L242
23,440
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.extractVariables
protected function extractVariables($content) { preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); if (!isset($matches[0], $matches[1])) { return []; } $return = []; $notifications = \Antares\Foundation\Notification::getInstance()->all(); foreach ($matches[1] as $index => $match) { if (!str_contains($match, '::')) { continue; } list($component, $var) = explode('::', trim($match)); $name = $this->findExtensionName($component); if (!$name) { continue; } $variables = $notifications[$name]['variables']; $return[$matches[0][$index]] = $this->resolveValue($var, $variables); } return $return; }
php
protected function extractVariables($content) { preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); if (!isset($matches[0], $matches[1])) { return []; } $return = []; $notifications = \Antares\Foundation\Notification::getInstance()->all(); foreach ($matches[1] as $index => $match) { if (!str_contains($match, '::')) { continue; } list($component, $var) = explode('::', trim($match)); $name = $this->findExtensionName($component); if (!$name) { continue; } $variables = $notifications[$name]['variables']; $return[$matches[0][$index]] = $this->resolveValue($var, $variables); } return $return; }
[ "protected", "function", "extractVariables", "(", "$", "content", ")", "{", "preg_match_all", "(", "'/\\[\\[(.*?)\\]\\]/'", ",", "$", "content", ",", "$", "matches", ")", ";", "if", "(", "!", "isset", "(", "$", "matches", "[", "0", "]", ",", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "[", "]", ";", "}", "$", "return", "=", "[", "]", ";", "$", "notifications", "=", "\\", "Antares", "\\", "Foundation", "\\", "Notification", "::", "getInstance", "(", ")", "->", "all", "(", ")", ";", "foreach", "(", "$", "matches", "[", "1", "]", "as", "$", "index", "=>", "$", "match", ")", "{", "if", "(", "!", "str_contains", "(", "$", "match", ",", "'::'", ")", ")", "{", "continue", ";", "}", "list", "(", "$", "component", ",", "$", "var", ")", "=", "explode", "(", "'::'", ",", "trim", "(", "$", "match", ")", ")", ";", "$", "name", "=", "$", "this", "->", "findExtensionName", "(", "$", "component", ")", ";", "if", "(", "!", "$", "name", ")", "{", "continue", ";", "}", "$", "variables", "=", "$", "notifications", "[", "$", "name", "]", "[", "'variables'", "]", ";", "$", "return", "[", "$", "matches", "[", "0", "]", "[", "$", "index", "]", "]", "=", "$", "this", "->", "resolveValue", "(", "$", "var", ",", "$", "variables", ")", ";", "}", "return", "$", "return", ";", "}" ]
extract variables from notification @param String $content @return array
[ "extract", "variables", "from", "notification" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L273-L296
23,441
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.fillContent
protected function fillContent($content) { preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); if (!isset($matches[0]) or ! isset($matches[1])) { return $content; } $notifications = \Antares\Foundation\Notification::getInstance()->all(); foreach ( (array) $matches[1] as $index => $match) { if (!str_contains($match, '::')) { continue; } list($component, $var) = explode('::', trim($match)); $name = $this->findExtensionName($component); $variables = isset($notifications[$name]['variables']) ? $notifications[$name]['variables'] : []; event('notifications:notification.variables', [&$variables]); $value = $this->resolveValue($var, $variables); if (is_array($value)) { $value = $this->getDefaultNotificationForList($value)->render(); } $content = str_replace($matches[0][$index], $value, $content); } return $content; }
php
protected function fillContent($content) { preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); if (!isset($matches[0]) or ! isset($matches[1])) { return $content; } $notifications = \Antares\Foundation\Notification::getInstance()->all(); foreach ( (array) $matches[1] as $index => $match) { if (!str_contains($match, '::')) { continue; } list($component, $var) = explode('::', trim($match)); $name = $this->findExtensionName($component); $variables = isset($notifications[$name]['variables']) ? $notifications[$name]['variables'] : []; event('notifications:notification.variables', [&$variables]); $value = $this->resolveValue($var, $variables); if (is_array($value)) { $value = $this->getDefaultNotificationForList($value)->render(); } $content = str_replace($matches[0][$index], $value, $content); } return $content; }
[ "protected", "function", "fillContent", "(", "$", "content", ")", "{", "preg_match_all", "(", "'/\\[\\[(.*?)\\]\\]/'", ",", "$", "content", ",", "$", "matches", ")", ";", "if", "(", "!", "isset", "(", "$", "matches", "[", "0", "]", ")", "or", "!", "isset", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "$", "content", ";", "}", "$", "notifications", "=", "\\", "Antares", "\\", "Foundation", "\\", "Notification", "::", "getInstance", "(", ")", "->", "all", "(", ")", ";", "foreach", "(", "(", "array", ")", "$", "matches", "[", "1", "]", "as", "$", "index", "=>", "$", "match", ")", "{", "if", "(", "!", "str_contains", "(", "$", "match", ",", "'::'", ")", ")", "{", "continue", ";", "}", "list", "(", "$", "component", ",", "$", "var", ")", "=", "explode", "(", "'::'", ",", "trim", "(", "$", "match", ")", ")", ";", "$", "name", "=", "$", "this", "->", "findExtensionName", "(", "$", "component", ")", ";", "$", "variables", "=", "isset", "(", "$", "notifications", "[", "$", "name", "]", "[", "'variables'", "]", ")", "?", "$", "notifications", "[", "$", "name", "]", "[", "'variables'", "]", ":", "[", "]", ";", "event", "(", "'notifications:notification.variables'", ",", "[", "&", "$", "variables", "]", ")", ";", "$", "value", "=", "$", "this", "->", "resolveValue", "(", "$", "var", ",", "$", "variables", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "getDefaultNotificationForList", "(", "$", "value", ")", "->", "render", "(", ")", ";", "}", "$", "content", "=", "str_replace", "(", "$", "matches", "[", "0", "]", "[", "$", "index", "]", ",", "$", "value", ",", "$", "content", ")", ";", "}", "return", "$", "content", ";", "}" ]
fills content with notification variables values @param String $content @return String
[ "fills", "content", "with", "notification", "variables", "values" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L304-L330
23,442
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.resolveValue
protected function resolveValue($name, $variables) { if (!empty($variables)) { foreach ($variables as $container => $vars) { foreach ($vars as $subname => $var) { $value = $var['value']; if(is_callable($value) && $var['name'] === $name) { return $value($this->variables); } if (isset($var['name']) and $name == $value and isset($value)) { return $value; } elseif (!isset($var['name']) and $subname == $name and isset($value)) { return $value; } } } } if (!isset($variables[$name])) { return false; } if (isset($variable['dataProvider'])) { $value = $this->resolveDataProviderValue($variable['dataProvider']); if (!$value) { return false; } return $value; } return array_get($variable, 'value', ''); }
php
protected function resolveValue($name, $variables) { if (!empty($variables)) { foreach ($variables as $container => $vars) { foreach ($vars as $subname => $var) { $value = $var['value']; if(is_callable($value) && $var['name'] === $name) { return $value($this->variables); } if (isset($var['name']) and $name == $value and isset($value)) { return $value; } elseif (!isset($var['name']) and $subname == $name and isset($value)) { return $value; } } } } if (!isset($variables[$name])) { return false; } if (isset($variable['dataProvider'])) { $value = $this->resolveDataProviderValue($variable['dataProvider']); if (!$value) { return false; } return $value; } return array_get($variable, 'value', ''); }
[ "protected", "function", "resolveValue", "(", "$", "name", ",", "$", "variables", ")", "{", "if", "(", "!", "empty", "(", "$", "variables", ")", ")", "{", "foreach", "(", "$", "variables", "as", "$", "container", "=>", "$", "vars", ")", "{", "foreach", "(", "$", "vars", "as", "$", "subname", "=>", "$", "var", ")", "{", "$", "value", "=", "$", "var", "[", "'value'", "]", ";", "if", "(", "is_callable", "(", "$", "value", ")", "&&", "$", "var", "[", "'name'", "]", "===", "$", "name", ")", "{", "return", "$", "value", "(", "$", "this", "->", "variables", ")", ";", "}", "if", "(", "isset", "(", "$", "var", "[", "'name'", "]", ")", "and", "$", "name", "==", "$", "value", "and", "isset", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "elseif", "(", "!", "isset", "(", "$", "var", "[", "'name'", "]", ")", "and", "$", "subname", "==", "$", "name", "and", "isset", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "}", "}", "}", "if", "(", "!", "isset", "(", "$", "variables", "[", "$", "name", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "variable", "[", "'dataProvider'", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "resolveDataProviderValue", "(", "$", "variable", "[", "'dataProvider'", "]", ")", ";", "if", "(", "!", "$", "value", ")", "{", "return", "false", ";", "}", "return", "$", "value", ";", "}", "return", "array_get", "(", "$", "variable", ",", "'value'", ",", "''", ")", ";", "}" ]
resolve notification variable value @param String $name @param array $variables @return mixed
[ "resolve", "notification", "variable", "value" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L339-L373
23,443
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.resolveDataProviderValue
protected function resolveDataProviderValue($dataProvider) { preg_match("/(.*)@(.*)/", $dataProvider, $matches); if (!isset($matches[1]) and ! isset($matches[2])) { return false; } if (!class_exists($matches[1])) { return false; } try { $instance = app($matches[1]); $return = call_user_func_array([$instance, $matches[2]], []); if ($return instanceof Builder) { return $return->get()->toArray(); } if ($return instanceof Collection) { return $return->toArray(); } return $return; } catch (Exception $ex) { return false; } }
php
protected function resolveDataProviderValue($dataProvider) { preg_match("/(.*)@(.*)/", $dataProvider, $matches); if (!isset($matches[1]) and ! isset($matches[2])) { return false; } if (!class_exists($matches[1])) { return false; } try { $instance = app($matches[1]); $return = call_user_func_array([$instance, $matches[2]], []); if ($return instanceof Builder) { return $return->get()->toArray(); } if ($return instanceof Collection) { return $return->toArray(); } return $return; } catch (Exception $ex) { return false; } }
[ "protected", "function", "resolveDataProviderValue", "(", "$", "dataProvider", ")", "{", "preg_match", "(", "\"/(.*)@(.*)/\"", ",", "$", "dataProvider", ",", "$", "matches", ")", ";", "if", "(", "!", "isset", "(", "$", "matches", "[", "1", "]", ")", "and", "!", "isset", "(", "$", "matches", "[", "2", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "class_exists", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "false", ";", "}", "try", "{", "$", "instance", "=", "app", "(", "$", "matches", "[", "1", "]", ")", ";", "$", "return", "=", "call_user_func_array", "(", "[", "$", "instance", ",", "$", "matches", "[", "2", "]", "]", ",", "[", "]", ")", ";", "if", "(", "$", "return", "instanceof", "Builder", ")", "{", "return", "$", "return", "->", "get", "(", ")", "->", "toArray", "(", ")", ";", "}", "if", "(", "$", "return", "instanceof", "Collection", ")", "{", "return", "$", "return", "->", "toArray", "(", ")", ";", "}", "return", "$", "return", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "return", "false", ";", "}", "}" ]
resolve notification variable value from data provider @param mixed $dataProvider @return boolean|Collection
[ "resolve", "notification", "variable", "value", "from", "data", "provider" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L381-L403
23,444
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.findExtensionName
protected function findExtensionName($name) { if ($name == 'foundation') { return $name; } $extensions = app('antares.memory')->make('component')->get('extensions.active'); foreach ($extensions as $keyname => $extension) { if ($name == $extension['name']) { return $keyname; } } return false; }
php
protected function findExtensionName($name) { if ($name == 'foundation') { return $name; } $extensions = app('antares.memory')->make('component')->get('extensions.active'); foreach ($extensions as $keyname => $extension) { if ($name == $extension['name']) { return $keyname; } } return false; }
[ "protected", "function", "findExtensionName", "(", "$", "name", ")", "{", "if", "(", "$", "name", "==", "'foundation'", ")", "{", "return", "$", "name", ";", "}", "$", "extensions", "=", "app", "(", "'antares.memory'", ")", "->", "make", "(", "'component'", ")", "->", "get", "(", "'extensions.active'", ")", ";", "foreach", "(", "$", "extensions", "as", "$", "keyname", "=>", "$", "extension", ")", "{", "if", "(", "$", "name", "==", "$", "extension", "[", "'name'", "]", ")", "{", "return", "$", "keyname", ";", "}", "}", "return", "false", ";", "}" ]
get extension key name by name from manifest @param type $name @return boolean|String
[ "get", "extension", "key", "name", "by", "name", "from", "manifest" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L411-L423
23,445
weew/http
src/Weew/Http/Cookies.php
Cookies.searchCookiesInHeaders
protected function searchCookiesInHeaders() { $headers = $this->holder->getHeaders()->get('set-cookie'); foreach ($headers as $header) { $cookie = $this->createCookieFromHeader($header); if ($cookie !== null) { $this->storeCookie($cookie); } } }
php
protected function searchCookiesInHeaders() { $headers = $this->holder->getHeaders()->get('set-cookie'); foreach ($headers as $header) { $cookie = $this->createCookieFromHeader($header); if ($cookie !== null) { $this->storeCookie($cookie); } } }
[ "protected", "function", "searchCookiesInHeaders", "(", ")", "{", "$", "headers", "=", "$", "this", "->", "holder", "->", "getHeaders", "(", ")", "->", "get", "(", "'set-cookie'", ")", ";", "foreach", "(", "$", "headers", "as", "$", "header", ")", "{", "$", "cookie", "=", "$", "this", "->", "createCookieFromHeader", "(", "$", "header", ")", ";", "if", "(", "$", "cookie", "!==", "null", ")", "{", "$", "this", "->", "storeCookie", "(", "$", "cookie", ")", ";", "}", "}", "}" ]
Parse headers for cookies.
[ "Parse", "headers", "for", "cookies", "." ]
fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/Cookies.php#L99-L109
23,446
surebert/surebert-framework
src/sb/Logger/Syslog.php
Syslog.save
public function save($log_dir = '') { if (empty($log_dir)) { $log_dir = \ROOT . '/private/logs/syslog/'; } if (!is_dir($log_dir)) { mkdir($log_dir, 0777, true); } return file_put_contents($log_dir . date('Y_m_d') . '.log', $this->message . "\n", \FILE_APPEND); }
php
public function save($log_dir = '') { if (empty($log_dir)) { $log_dir = \ROOT . '/private/logs/syslog/'; } if (!is_dir($log_dir)) { mkdir($log_dir, 0777, true); } return file_put_contents($log_dir . date('Y_m_d') . '.log', $this->message . "\n", \FILE_APPEND); }
[ "public", "function", "save", "(", "$", "log_dir", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "log_dir", ")", ")", "{", "$", "log_dir", "=", "\\", "ROOT", ".", "'/private/logs/syslog/'", ";", "}", "if", "(", "!", "is_dir", "(", "$", "log_dir", ")", ")", "{", "mkdir", "(", "$", "log_dir", ",", "0777", ",", "true", ")", ";", "}", "return", "file_put_contents", "(", "$", "log_dir", ".", "date", "(", "'Y_m_d'", ")", ".", "'.log'", ",", "$", "this", "->", "message", ".", "\"\\n\"", ",", "\\", "FILE_APPEND", ")", ";", "}" ]
Saves data to local logs dir when syslog server is not available @param string $log_dir The log dir the data is written to @param string $log_type The log_type being written to @return boolean If the data was written or not
[ "Saves", "data", "to", "local", "logs", "dir", "when", "syslog", "server", "is", "not", "available" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Logger/Syslog.php#L199-L211
23,447
surebert/surebert-framework
src/sb/Logger/Syslog.php
Syslog.checkLength
protected function checkLength($str, $max_length = '', $type = 'packet') { $max_length = $max_length ? $max_length : $this->max_length; if ($max_length == -1) { return $str; } $strlen = strlen($str); if ($strlen > $max_length) { throw new \Exception("Syslog " . $type . " is > " . $max_length . " (" . $strlen . ") in length and will be truncated. Original str is: " . $str, E_USER_WARNING); return substr($str, 0, $max_length); } return $str; }
php
protected function checkLength($str, $max_length = '', $type = 'packet') { $max_length = $max_length ? $max_length : $this->max_length; if ($max_length == -1) { return $str; } $strlen = strlen($str); if ($strlen > $max_length) { throw new \Exception("Syslog " . $type . " is > " . $max_length . " (" . $strlen . ") in length and will be truncated. Original str is: " . $str, E_USER_WARNING); return substr($str, 0, $max_length); } return $str; }
[ "protected", "function", "checkLength", "(", "$", "str", ",", "$", "max_length", "=", "''", ",", "$", "type", "=", "'packet'", ")", "{", "$", "max_length", "=", "$", "max_length", "?", "$", "max_length", ":", "$", "this", "->", "max_length", ";", "if", "(", "$", "max_length", "==", "-", "1", ")", "{", "return", "$", "str", ";", "}", "$", "strlen", "=", "strlen", "(", "$", "str", ")", ";", "if", "(", "$", "strlen", ">", "$", "max_length", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Syslog \"", ".", "$", "type", ".", "\" is > \"", ".", "$", "max_length", ".", "\" (\"", ".", "$", "strlen", ".", "\") in length and will be truncated. Original str is: \"", ".", "$", "str", ",", "E_USER_WARNING", ")", ";", "return", "substr", "(", "$", "str", ",", "0", ",", "$", "max_length", ")", ";", "}", "return", "$", "str", ";", "}" ]
Checks to make sure the length of something is expected or warn and truncate @param string $str The string to check @param int $max_length The maximun length to check for, -1 means infinite length @param string $type The type of thing to check packet or process @return string The string truncated to max length
[ "Checks", "to", "make", "sure", "the", "length", "of", "something", "is", "expected", "or", "warn", "and", "truncate" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Logger/Syslog.php#L262-L276
23,448
xiewulong/yii2-fileupload
oss/libs/symfony/yaml/Symfony/Component/Yaml/Yaml.php
Yaml.parse
public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false) { // if input is a file, process it $file = ''; if (strpos($input, "\n") === false && is_file($input)) { if (false === is_readable($input)) { throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input)); } $file = $input; $input = file_get_contents($file); } $yaml = new Parser(); try { return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport); } catch (ParseException $e) { if ($file) { $e->setParsedFile($file); } throw $e; } }
php
public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false) { // if input is a file, process it $file = ''; if (strpos($input, "\n") === false && is_file($input)) { if (false === is_readable($input)) { throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input)); } $file = $input; $input = file_get_contents($file); } $yaml = new Parser(); try { return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport); } catch (ParseException $e) { if ($file) { $e->setParsedFile($file); } throw $e; } }
[ "public", "static", "function", "parse", "(", "$", "input", ",", "$", "exceptionOnInvalidType", "=", "false", ",", "$", "objectSupport", "=", "false", ")", "{", "// if input is a file, process it", "$", "file", "=", "''", ";", "if", "(", "strpos", "(", "$", "input", ",", "\"\\n\"", ")", "===", "false", "&&", "is_file", "(", "$", "input", ")", ")", "{", "if", "(", "false", "===", "is_readable", "(", "$", "input", ")", ")", "{", "throw", "new", "ParseException", "(", "sprintf", "(", "'Unable to parse \"%s\" as the file is not readable.'", ",", "$", "input", ")", ")", ";", "}", "$", "file", "=", "$", "input", ";", "$", "input", "=", "file_get_contents", "(", "$", "file", ")", ";", "}", "$", "yaml", "=", "new", "Parser", "(", ")", ";", "try", "{", "return", "$", "yaml", "->", "parse", "(", "$", "input", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", ";", "}", "catch", "(", "ParseException", "$", "e", ")", "{", "if", "(", "$", "file", ")", "{", "$", "e", "->", "setParsedFile", "(", "$", "file", ")", ";", "}", "throw", "$", "e", ";", "}", "}" ]
Parses YAML into a PHP array. The parse method, when supplied with a YAML stream (string or file), will do its best to convert YAML in a file into a PHP array. Usage: <code> $array = Yaml::parse('config.yml'); print_r($array); </code> As this method accepts both plain strings and file names as an input, you must validate the input before calling this method. Passing a file as an input is a deprecated feature and will be removed in 3.0. @param string $input Path to a YAML file or a string containing YAML @param Boolean $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise @param Boolean $objectSupport True if object support is enabled, false otherwise @return array The YAML converted to a PHP array @throws ParseException If the YAML is not valid @api
[ "Parses", "YAML", "into", "a", "PHP", "array", "." ]
3e75b17a4a18dd8466e3f57c63136de03470ca82
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/yaml/Symfony/Component/Yaml/Yaml.php#L51-L75
23,449
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Viewer/Json.php
Json.getSpacerType
protected function getSpacerType() { $type = ""; if(!$this->currObj instanceof Channel || !$this->currObj->isSpacer()) { return "none"; } switch($this->currObj->spacerGetType()) { case (string) TeamSpeak3::SPACER_SOLIDLINE: $type .= "solidline"; break; case (string) TeamSpeak3::SPACER_DASHLINE: $type .= "dashline"; break; case (string) TeamSpeak3::SPACER_DASHDOTLINE: $type .= "dashdotline"; break; case (string) TeamSpeak3::SPACER_DASHDOTDOTLINE: $type .= "dashdotdotline"; break; case (string) TeamSpeak3::SPACER_DOTLINE: $type .= "dotline"; break; default: $type .= "custom"; } if($type == "custom") { switch($this->currObj->spacerGetAlign()) { case TeamSpeak3::SPACER_ALIGN_REPEAT: $type .= "repeat"; break; case TeamSpeak3::SPACER_ALIGN_CENTER: $type .= "center"; break; case TeamSpeak3::SPACER_ALIGN_RIGHT: $type .= "right"; break; default: $type .= "left"; } } return $type; }
php
protected function getSpacerType() { $type = ""; if(!$this->currObj instanceof Channel || !$this->currObj->isSpacer()) { return "none"; } switch($this->currObj->spacerGetType()) { case (string) TeamSpeak3::SPACER_SOLIDLINE: $type .= "solidline"; break; case (string) TeamSpeak3::SPACER_DASHLINE: $type .= "dashline"; break; case (string) TeamSpeak3::SPACER_DASHDOTLINE: $type .= "dashdotline"; break; case (string) TeamSpeak3::SPACER_DASHDOTDOTLINE: $type .= "dashdotdotline"; break; case (string) TeamSpeak3::SPACER_DOTLINE: $type .= "dotline"; break; default: $type .= "custom"; } if($type == "custom") { switch($this->currObj->spacerGetAlign()) { case TeamSpeak3::SPACER_ALIGN_REPEAT: $type .= "repeat"; break; case TeamSpeak3::SPACER_ALIGN_CENTER: $type .= "center"; break; case TeamSpeak3::SPACER_ALIGN_RIGHT: $type .= "right"; break; default: $type .= "left"; } } return $type; }
[ "protected", "function", "getSpacerType", "(", ")", "{", "$", "type", "=", "\"\"", ";", "if", "(", "!", "$", "this", "->", "currObj", "instanceof", "Channel", "||", "!", "$", "this", "->", "currObj", "->", "isSpacer", "(", ")", ")", "{", "return", "\"none\"", ";", "}", "switch", "(", "$", "this", "->", "currObj", "->", "spacerGetType", "(", ")", ")", "{", "case", "(", "string", ")", "TeamSpeak3", "::", "SPACER_SOLIDLINE", ":", "$", "type", ".=", "\"solidline\"", ";", "break", ";", "case", "(", "string", ")", "TeamSpeak3", "::", "SPACER_DASHLINE", ":", "$", "type", ".=", "\"dashline\"", ";", "break", ";", "case", "(", "string", ")", "TeamSpeak3", "::", "SPACER_DASHDOTLINE", ":", "$", "type", ".=", "\"dashdotline\"", ";", "break", ";", "case", "(", "string", ")", "TeamSpeak3", "::", "SPACER_DASHDOTDOTLINE", ":", "$", "type", ".=", "\"dashdotdotline\"", ";", "break", ";", "case", "(", "string", ")", "TeamSpeak3", "::", "SPACER_DOTLINE", ":", "$", "type", ".=", "\"dotline\"", ";", "break", ";", "default", ":", "$", "type", ".=", "\"custom\"", ";", "}", "if", "(", "$", "type", "==", "\"custom\"", ")", "{", "switch", "(", "$", "this", "->", "currObj", "->", "spacerGetAlign", "(", ")", ")", "{", "case", "TeamSpeak3", "::", "SPACER_ALIGN_REPEAT", ":", "$", "type", ".=", "\"repeat\"", ";", "break", ";", "case", "TeamSpeak3", "::", "SPACER_ALIGN_CENTER", ":", "$", "type", ".=", "\"center\"", ";", "break", ";", "case", "TeamSpeak3", "::", "SPACER_ALIGN_RIGHT", ":", "$", "type", ".=", "\"right\"", ";", "break", ";", "default", ":", "$", "type", ".=", "\"left\"", ";", "}", "}", "return", "$", "type", ";", "}" ]
Returns an individual type for a spacer. @return string
[ "Returns", "an", "individual", "type", "for", "a", "spacer", "." ]
39a56eca608da6b56b6aa386a7b5b31dc576c41a
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Viewer/Json.php#L266-L323
23,450
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Viewer/Json.php
Json.getName
protected function getName() { if($this->currObj instanceof Channel && $this->currObj->isSpacer()) { return $this->currObj["channel_name"]->section("]", 1, 99)->toString(); } elseif($this->currObj instanceof Client) { $before = array(); $behind = array(); foreach($this->currObj->memberOf() as $group) { if($group->getProperty("namemode") == TeamSpeak3::GROUP_NAMEMODE_BEFORE) { $before[] = "[" . $group["name"] . "]"; } elseif($group->getProperty("namemode") == TeamSpeak3::GROUP_NAMEMODE_BEHIND) { $behind[] = "[" . $group["name"] . "]"; } } return trim(implode("", $before) . " " . $this->currObj . " " . implode("", $behind)); } return $this->currObj->toString(); }
php
protected function getName() { if($this->currObj instanceof Channel && $this->currObj->isSpacer()) { return $this->currObj["channel_name"]->section("]", 1, 99)->toString(); } elseif($this->currObj instanceof Client) { $before = array(); $behind = array(); foreach($this->currObj->memberOf() as $group) { if($group->getProperty("namemode") == TeamSpeak3::GROUP_NAMEMODE_BEFORE) { $before[] = "[" . $group["name"] . "]"; } elseif($group->getProperty("namemode") == TeamSpeak3::GROUP_NAMEMODE_BEHIND) { $behind[] = "[" . $group["name"] . "]"; } } return trim(implode("", $before) . " " . $this->currObj . " " . implode("", $behind)); } return $this->currObj->toString(); }
[ "protected", "function", "getName", "(", ")", "{", "if", "(", "$", "this", "->", "currObj", "instanceof", "Channel", "&&", "$", "this", "->", "currObj", "->", "isSpacer", "(", ")", ")", "{", "return", "$", "this", "->", "currObj", "[", "\"channel_name\"", "]", "->", "section", "(", "\"]\"", ",", "1", ",", "99", ")", "->", "toString", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "currObj", "instanceof", "Client", ")", "{", "$", "before", "=", "array", "(", ")", ";", "$", "behind", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "currObj", "->", "memberOf", "(", ")", "as", "$", "group", ")", "{", "if", "(", "$", "group", "->", "getProperty", "(", "\"namemode\"", ")", "==", "TeamSpeak3", "::", "GROUP_NAMEMODE_BEFORE", ")", "{", "$", "before", "[", "]", "=", "\"[\"", ".", "$", "group", "[", "\"name\"", "]", ".", "\"]\"", ";", "}", "elseif", "(", "$", "group", "->", "getProperty", "(", "\"namemode\"", ")", "==", "TeamSpeak3", "::", "GROUP_NAMEMODE_BEHIND", ")", "{", "$", "behind", "[", "]", "=", "\"[\"", ".", "$", "group", "[", "\"name\"", "]", ".", "\"]\"", ";", "}", "}", "return", "trim", "(", "implode", "(", "\"\"", ",", "$", "before", ")", ".", "\" \"", ".", "$", "this", "->", "currObj", ".", "\" \"", ".", "implode", "(", "\"\"", ",", "$", "behind", ")", ")", ";", "}", "return", "$", "this", "->", "currObj", "->", "toString", "(", ")", ";", "}" ]
Returns a string for the current corpus element which contains the display name for the current TeamSpeak_Node_Abstract object. @return string
[ "Returns", "a", "string", "for", "the", "current", "corpus", "element", "which", "contains", "the", "display", "name", "for", "the", "current", "TeamSpeak_Node_Abstract", "object", "." ]
39a56eca608da6b56b6aa386a7b5b31dc576c41a
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Viewer/Json.php#L331-L358
23,451
surebert/surebert-framework
src/sb/Cache/APC.php
APC.store
public function store($key, $data, $lifetime = 0) { $key = $this->namespace . $key; $store = apc_store($key, $data, $lifetime); if ($store && $key != $this->namespace . $this->catalog_key) { $this->catalogKeyAdd($key, $lifetime); } return $store; }
php
public function store($key, $data, $lifetime = 0) { $key = $this->namespace . $key; $store = apc_store($key, $data, $lifetime); if ($store && $key != $this->namespace . $this->catalog_key) { $this->catalogKeyAdd($key, $lifetime); } return $store; }
[ "public", "function", "store", "(", "$", "key", ",", "$", "data", ",", "$", "lifetime", "=", "0", ")", "{", "$", "key", "=", "$", "this", "->", "namespace", ".", "$", "key", ";", "$", "store", "=", "apc_store", "(", "$", "key", ",", "$", "data", ",", "$", "lifetime", ")", ";", "if", "(", "$", "store", "&&", "$", "key", "!=", "$", "this", "->", "namespace", ".", "$", "this", "->", "catalog_key", ")", "{", "$", "this", "->", "catalogKeyAdd", "(", "$", "key", ",", "$", "lifetime", ")", ";", "}", "return", "$", "store", ";", "}" ]
Store the cache data in APC
[ "Store", "the", "cache", "data", "in", "APC" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/APC.php#L41-L51
23,452
surebert/surebert-framework
src/sb/Cache/APC.php
APC.catalogKeyAdd
private function catalogKeyAdd($key, $lifetime) { $catalog = $this->fetch($this->catalog_key); $catalog = is_array($catalog) ? $catalog : Array(); $catalog[$key] = ($lifetime == 0) ? $lifetime : $lifetime + time(); return $this->store($this->catalog_key, $catalog); }
php
private function catalogKeyAdd($key, $lifetime) { $catalog = $this->fetch($this->catalog_key); $catalog = is_array($catalog) ? $catalog : Array(); $catalog[$key] = ($lifetime == 0) ? $lifetime : $lifetime + time(); return $this->store($this->catalog_key, $catalog); }
[ "private", "function", "catalogKeyAdd", "(", "$", "key", ",", "$", "lifetime", ")", "{", "$", "catalog", "=", "$", "this", "->", "fetch", "(", "$", "this", "->", "catalog_key", ")", ";", "$", "catalog", "=", "is_array", "(", "$", "catalog", ")", "?", "$", "catalog", ":", "Array", "(", ")", ";", "$", "catalog", "[", "$", "key", "]", "=", "(", "$", "lifetime", "==", "0", ")", "?", "$", "lifetime", ":", "$", "lifetime", "+", "time", "(", ")", ";", "return", "$", "this", "->", "store", "(", "$", "this", "->", "catalog_key", ",", "$", "catalog", ")", ";", "}" ]
Keeps track of the data stored in the cache to make deleting groups of data possible @param $key @return boolean If the catalog is stored or not
[ "Keeps", "track", "of", "the", "data", "stored", "in", "the", "cache", "to", "make", "deleting", "groups", "of", "data", "possible" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/APC.php#L101-L108
23,453
webdevvie/pheanstalk-task-queue-bundle
TaskDescription/AbstractTaskDescription.php
AbstractTaskDescription.getOptions
public function getOptions() { $options = array(); foreach ($this->commandOptions as $key => $value) { $options[$key]=$this->$value; } return $options; }
php
public function getOptions() { $options = array(); foreach ($this->commandOptions as $key => $value) { $options[$key]=$this->$value; } return $options; }
[ "public", "function", "getOptions", "(", ")", "{", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "commandOptions", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "options", "[", "$", "key", "]", "=", "$", "this", "->", "$", "value", ";", "}", "return", "$", "options", ";", "}" ]
Returns a two dimensional array of options to pass to the command The key is the @return array
[ "Returns", "a", "two", "dimensional", "array", "of", "options", "to", "pass", "to", "the", "command", "The", "key", "is", "the" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/TaskDescription/AbstractTaskDescription.php#L68-L75
23,454
webdevvie/pheanstalk-task-queue-bundle
TaskDescription/AbstractTaskDescription.php
AbstractTaskDescription.getArguments
public function getArguments() { $arguments = array(); foreach ($this->commandArguments as $argument) { $arguments[] = $this->$argument; } return $arguments; }
php
public function getArguments() { $arguments = array(); foreach ($this->commandArguments as $argument) { $arguments[] = $this->$argument; } return $arguments; }
[ "public", "function", "getArguments", "(", ")", "{", "$", "arguments", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "commandArguments", "as", "$", "argument", ")", "{", "$", "arguments", "[", "]", "=", "$", "this", "->", "$", "argument", ";", "}", "return", "$", "arguments", ";", "}" ]
Returns a one dimensional array of arguments to pass to the command @return array
[ "Returns", "a", "one", "dimensional", "array", "of", "arguments", "to", "pass", "to", "the", "command" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/TaskDescription/AbstractTaskDescription.php#L82-L89
23,455
DevGroup-ru/yii2-users-module
src/models/UserModuleConfiguration.php
UserModuleConfiguration.commonApplicationAttributes
public function commonApplicationAttributes() { return [ 'modules' => [ 'users' => [ 'emailConfirmationNeeded' => (bool)$this->emailConfirmationNeeded, 'allowLoginInactiveAccounts' => (bool)$this->allowLoginInactiveAccounts, 'enableSocialNetworks' => (bool)$this->enableSocialNetworks, 'logLastLoginTime' => (bool)$this->logLastLoginTime, 'logLastLoginData' => (bool)$this->logLastLoginData, 'passwordResetTokenExpire' => (int)$this->passwordResetTokenExpire, 'loginDuration' => (int)$this->loginDuration, 'generatedPasswordLength' => (int)$this->generatedPasswordLength, ] ], ]; }
php
public function commonApplicationAttributes() { return [ 'modules' => [ 'users' => [ 'emailConfirmationNeeded' => (bool)$this->emailConfirmationNeeded, 'allowLoginInactiveAccounts' => (bool)$this->allowLoginInactiveAccounts, 'enableSocialNetworks' => (bool)$this->enableSocialNetworks, 'logLastLoginTime' => (bool)$this->logLastLoginTime, 'logLastLoginData' => (bool)$this->logLastLoginData, 'passwordResetTokenExpire' => (int)$this->passwordResetTokenExpire, 'loginDuration' => (int)$this->loginDuration, 'generatedPasswordLength' => (int)$this->generatedPasswordLength, ] ], ]; }
[ "public", "function", "commonApplicationAttributes", "(", ")", "{", "return", "[", "'modules'", "=>", "[", "'users'", "=>", "[", "'emailConfirmationNeeded'", "=>", "(", "bool", ")", "$", "this", "->", "emailConfirmationNeeded", ",", "'allowLoginInactiveAccounts'", "=>", "(", "bool", ")", "$", "this", "->", "allowLoginInactiveAccounts", ",", "'enableSocialNetworks'", "=>", "(", "bool", ")", "$", "this", "->", "enableSocialNetworks", ",", "'logLastLoginTime'", "=>", "(", "bool", ")", "$", "this", "->", "logLastLoginTime", ",", "'logLastLoginData'", "=>", "(", "bool", ")", "$", "this", "->", "logLastLoginData", ",", "'passwordResetTokenExpire'", "=>", "(", "int", ")", "$", "this", "->", "passwordResetTokenExpire", ",", "'loginDuration'", "=>", "(", "int", ")", "$", "this", "->", "loginDuration", ",", "'generatedPasswordLength'", "=>", "(", "int", ")", "$", "this", "->", "generatedPasswordLength", ",", "]", "]", ",", "]", ";", "}" ]
Returns array of module configuration that should be stored in application config. Array should be ready to merge in app config. Used both for web and console. @return array
[ "Returns", "array", "of", "module", "configuration", "that", "should", "be", "stored", "in", "application", "config", ".", "Array", "should", "be", "ready", "to", "merge", "in", "app", "config", ".", "Used", "both", "for", "web", "and", "console", "." ]
ff0103dc55c3462627ccc704c33e70c96053f750
https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/UserModuleConfiguration.php#L54-L70
23,456
GrupaZero/social
src/Gzero/Social/Controller/SocialAuthController.php
SocialAuthController.socialLogin
public function socialLogin($serviceName) { if (config('services.' . $serviceName)) { $this->setDynamicRedirectUrl($serviceName); return $this->socialite->driver($serviceName)->redirect(); } return redirect('/'); }
php
public function socialLogin($serviceName) { if (config('services.' . $serviceName)) { $this->setDynamicRedirectUrl($serviceName); return $this->socialite->driver($serviceName)->redirect(); } return redirect('/'); }
[ "public", "function", "socialLogin", "(", "$", "serviceName", ")", "{", "if", "(", "config", "(", "'services.'", ".", "$", "serviceName", ")", ")", "{", "$", "this", "->", "setDynamicRedirectUrl", "(", "$", "serviceName", ")", ";", "return", "$", "this", "->", "socialite", "->", "driver", "(", "$", "serviceName", ")", "->", "redirect", "(", ")", ";", "}", "return", "redirect", "(", "'/'", ")", ";", "}" ]
Function responsible for login the user by the given social service. @param $serviceName string social service name @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\RedirectResponse
[ "Function", "responsible", "for", "login", "the", "user", "by", "the", "given", "social", "service", "." ]
f7cbf50765bd228010a2c61d950f915828306cf7
https://github.com/GrupaZero/social/blob/f7cbf50765bd228010a2c61d950f915828306cf7/src/Gzero/Social/Controller/SocialAuthController.php#L48-L55
23,457
GrupaZero/social
src/Gzero/Social/Controller/SocialAuthController.php
SocialAuthController.socialCallback
public function socialCallback(Request $request, $serviceName) { try { $this->setDynamicRedirectUrl($serviceName); $user = $this->socialite->driver($serviceName)->user(); $this->authService->login($serviceName, $user); return redirect(session('url.intended', '/')); } catch (\Exception $e) { Log::error('Social login failed: ' . $e->getMessage() . ' - ' . print_r($request->all(), true)); if (session()->has('url.intended')) { // If redirect url exists show translated error to the user $reditectUrl = session('url.intended'); session()->forget('url.intended'); // remove intended url // Set flash message session()->flash( 'messages', [ [ 'code' => 'error', 'text' => $e->getMessage() ] ] ); return redirect($reditectUrl); } else { return app()->abort(500, $e->getMessage()); } } }
php
public function socialCallback(Request $request, $serviceName) { try { $this->setDynamicRedirectUrl($serviceName); $user = $this->socialite->driver($serviceName)->user(); $this->authService->login($serviceName, $user); return redirect(session('url.intended', '/')); } catch (\Exception $e) { Log::error('Social login failed: ' . $e->getMessage() . ' - ' . print_r($request->all(), true)); if (session()->has('url.intended')) { // If redirect url exists show translated error to the user $reditectUrl = session('url.intended'); session()->forget('url.intended'); // remove intended url // Set flash message session()->flash( 'messages', [ [ 'code' => 'error', 'text' => $e->getMessage() ] ] ); return redirect($reditectUrl); } else { return app()->abort(500, $e->getMessage()); } } }
[ "public", "function", "socialCallback", "(", "Request", "$", "request", ",", "$", "serviceName", ")", "{", "try", "{", "$", "this", "->", "setDynamicRedirectUrl", "(", "$", "serviceName", ")", ";", "$", "user", "=", "$", "this", "->", "socialite", "->", "driver", "(", "$", "serviceName", ")", "->", "user", "(", ")", ";", "$", "this", "->", "authService", "->", "login", "(", "$", "serviceName", ",", "$", "user", ")", ";", "return", "redirect", "(", "session", "(", "'url.intended'", ",", "'/'", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "Log", "::", "error", "(", "'Social login failed: '", ".", "$", "e", "->", "getMessage", "(", ")", ".", "' - '", ".", "print_r", "(", "$", "request", "->", "all", "(", ")", ",", "true", ")", ")", ";", "if", "(", "session", "(", ")", "->", "has", "(", "'url.intended'", ")", ")", "{", "// If redirect url exists show translated error to the user", "$", "reditectUrl", "=", "session", "(", "'url.intended'", ")", ";", "session", "(", ")", "->", "forget", "(", "'url.intended'", ")", ";", "// remove intended url", "// Set flash message", "session", "(", ")", "->", "flash", "(", "'messages'", ",", "[", "[", "'code'", "=>", "'error'", ",", "'text'", "=>", "$", "e", "->", "getMessage", "(", ")", "]", "]", ")", ";", "return", "redirect", "(", "$", "reditectUrl", ")", ";", "}", "else", "{", "return", "app", "(", ")", "->", "abort", "(", "500", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "}" ]
Function responsible for handle a callback request from the given social service. @param Request $request Request object @param string $serviceName string social service name @return \Illuminate\Http\RedirectResponse
[ "Function", "responsible", "for", "handle", "a", "callback", "request", "from", "the", "given", "social", "service", "." ]
f7cbf50765bd228010a2c61d950f915828306cf7
https://github.com/GrupaZero/social/blob/f7cbf50765bd228010a2c61d950f915828306cf7/src/Gzero/Social/Controller/SocialAuthController.php#L65-L92
23,458
philippfrenzel/yii2instafeed
yii2instafeed.php
yii2instafeed.registerPlugin
protected function registerPlugin() { $id = $this->options['id']; //get the displayed view and register the needed assets $view = $this->getView(); yii2instafeedAsset::register($view); $js = array(); $options = Json::encode($this->clientOptions); $js[] = "var feed$id = new Instafeed($options);"; $js[] = "feed$id.run();"; $view->registerJs(implode("\n", $js),View::POS_READY); }
php
protected function registerPlugin() { $id = $this->options['id']; //get the displayed view and register the needed assets $view = $this->getView(); yii2instafeedAsset::register($view); $js = array(); $options = Json::encode($this->clientOptions); $js[] = "var feed$id = new Instafeed($options);"; $js[] = "feed$id.run();"; $view->registerJs(implode("\n", $js),View::POS_READY); }
[ "protected", "function", "registerPlugin", "(", ")", "{", "$", "id", "=", "$", "this", "->", "options", "[", "'id'", "]", ";", "//get the displayed view and register the needed assets", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "yii2instafeedAsset", "::", "register", "(", "$", "view", ")", ";", "$", "js", "=", "array", "(", ")", ";", "$", "options", "=", "Json", "::", "encode", "(", "$", "this", "->", "clientOptions", ")", ";", "$", "js", "[", "]", "=", "\"var feed$id = new Instafeed($options);\"", ";", "$", "js", "[", "]", "=", "\"feed$id.run();\"", ";", "$", "view", "->", "registerJs", "(", "implode", "(", "\"\\n\"", ",", "$", "js", ")", ",", "View", "::", "POS_READY", ")", ";", "}" ]
Registers a specific dhtmlx widget and the related events @param string $name the name of the dhtmlx plugin
[ "Registers", "a", "specific", "dhtmlx", "widget", "and", "the", "related", "events" ]
8578ce03db39088590e931b8e336d7aca863ed6f
https://github.com/philippfrenzel/yii2instafeed/blob/8578ce03db39088590e931b8e336d7aca863ed6f/yii2instafeed.php#L71-L86
23,459
phpnfe/tools
src/Certificado/Certificado.php
Certificado.salvarArquivo
public function salvarArquivo($arquivo) { // Verificando se a chave pública está nula $this->verificaChaveNula(); $xml = file_get_contents(__DIR__ . '/../Templates/certificado.xml'); $xml = str_replace('{{chave_pub}}', $this->chavePub, $xml); $xml = str_replace('{{chave_pri}}', $this->chavePri, $xml); file_put_contents($arquivo, $xml); return true; }
php
public function salvarArquivo($arquivo) { // Verificando se a chave pública está nula $this->verificaChaveNula(); $xml = file_get_contents(__DIR__ . '/../Templates/certificado.xml'); $xml = str_replace('{{chave_pub}}', $this->chavePub, $xml); $xml = str_replace('{{chave_pri}}', $this->chavePri, $xml); file_put_contents($arquivo, $xml); return true; }
[ "public", "function", "salvarArquivo", "(", "$", "arquivo", ")", "{", "// Verificando se a chave pública está nula", "$", "this", "->", "verificaChaveNula", "(", ")", ";", "$", "xml", "=", "file_get_contents", "(", "__DIR__", ".", "'/../Templates/certificado.xml'", ")", ";", "$", "xml", "=", "str_replace", "(", "'{{chave_pub}}'", ",", "$", "this", "->", "chavePub", ",", "$", "xml", ")", ";", "$", "xml", "=", "str_replace", "(", "'{{chave_pri}}'", ",", "$", "this", "->", "chavePri", ",", "$", "xml", ")", ";", "file_put_contents", "(", "$", "arquivo", ",", "$", "xml", ")", ";", "return", "true", ";", "}" ]
Salva um arquivo com as propriedades do certificado. @param $arquivo @return bool
[ "Salva", "um", "arquivo", "com", "as", "propriedades", "do", "certificado", "." ]
303ca311989e0b345071f61b71d2b3bf7ee80454
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Certificado.php#L69-L81
23,460
phpnfe/tools
src/Certificado/Certificado.php
Certificado.getValidade
public function getValidade() { $this->verificaChaveNula(); $data = openssl_x509_read($this->chavePub); $certData = openssl_x509_parse($data); return Carbon::createFromFormat('ymdHis', str_replace('Z', '', $certData['validTo'])); }
php
public function getValidade() { $this->verificaChaveNula(); $data = openssl_x509_read($this->chavePub); $certData = openssl_x509_parse($data); return Carbon::createFromFormat('ymdHis', str_replace('Z', '', $certData['validTo'])); }
[ "public", "function", "getValidade", "(", ")", "{", "$", "this", "->", "verificaChaveNula", "(", ")", ";", "$", "data", "=", "openssl_x509_read", "(", "$", "this", "->", "chavePub", ")", ";", "$", "certData", "=", "openssl_x509_parse", "(", "$", "data", ")", ";", "return", "Carbon", "::", "createFromFormat", "(", "'ymdHis'", ",", "str_replace", "(", "'Z'", ",", "''", ",", "$", "certData", "[", "'validTo'", "]", ")", ")", ";", "}" ]
Retorna a data e hora da validade do certificado. @return Carbon
[ "Retorna", "a", "data", "e", "hora", "da", "validade", "do", "certificado", "." ]
303ca311989e0b345071f61b71d2b3bf7ee80454
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Certificado.php#L110-L118
23,461
raideer/twitch-api
src/Resources/Follows.php
Follows.getFollows
public function getFollows($user, $params = []) { $defaults = [ 'limit' => 25, 'offset' => 0, 'direction' => 'desc', 'sortby' => 'created_at', ]; return $this->wrapper->request('GET', "users/$user/follows/channels", ['query' => $this->resolveOptions($params, $defaults)]); }
php
public function getFollows($user, $params = []) { $defaults = [ 'limit' => 25, 'offset' => 0, 'direction' => 'desc', 'sortby' => 'created_at', ]; return $this->wrapper->request('GET', "users/$user/follows/channels", ['query' => $this->resolveOptions($params, $defaults)]); }
[ "public", "function", "getFollows", "(", "$", "user", ",", "$", "params", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'limit'", "=>", "25", ",", "'offset'", "=>", "0", ",", "'direction'", "=>", "'desc'", ",", "'sortby'", "=>", "'created_at'", ",", "]", ";", "return", "$", "this", "->", "wrapper", "->", "request", "(", "'GET'", ",", "\"users/$user/follows/channels\"", ",", "[", "'query'", "=>", "$", "this", "->", "resolveOptions", "(", "$", "params", ",", "$", "defaults", ")", "]", ")", ";", "}" ]
Returns a list of follows objects. Learn more: https://github.com/justintv/Twitch-API/blob/master/v3_resources/follows.md#get-usersuserfollowschannels @param string $user Target user @param array $params List of parameters @return object
[ "Returns", "a", "list", "of", "follows", "objects", "." ]
27ebf1dcb0315206300d507600b6a82ebe33d57e
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Follows.php#L54-L64
23,462
Rxnet/rabbitmq
Client.php
Client.channel
public function channel($bind = []): Observable { $this->bunny = $this->bunny ?? new BaseAsynchClient($this->loop, $this->configuration); if (!\is_array($bind)) { $bind = \func_get_args(); } return Observable::fromPromise( $this->bunny ->connect() ->then(function (BaseAsynchClient $client) { return $client->channel(); }) ->then(function (Channel $channel) use ($bind) { foreach ($bind as $obj) { $obj->setChannel($channel); } return $channel; }) ); }
php
public function channel($bind = []): Observable { $this->bunny = $this->bunny ?? new BaseAsynchClient($this->loop, $this->configuration); if (!\is_array($bind)) { $bind = \func_get_args(); } return Observable::fromPromise( $this->bunny ->connect() ->then(function (BaseAsynchClient $client) { return $client->channel(); }) ->then(function (Channel $channel) use ($bind) { foreach ($bind as $obj) { $obj->setChannel($channel); } return $channel; }) ); }
[ "public", "function", "channel", "(", "$", "bind", "=", "[", "]", ")", ":", "Observable", "{", "$", "this", "->", "bunny", "=", "$", "this", "->", "bunny", "??", "new", "BaseAsynchClient", "(", "$", "this", "->", "loop", ",", "$", "this", "->", "configuration", ")", ";", "if", "(", "!", "\\", "is_array", "(", "$", "bind", ")", ")", "{", "$", "bind", "=", "\\", "func_get_args", "(", ")", ";", "}", "return", "Observable", "::", "fromPromise", "(", "$", "this", "->", "bunny", "->", "connect", "(", ")", "->", "then", "(", "function", "(", "BaseAsynchClient", "$", "client", ")", "{", "return", "$", "client", "->", "channel", "(", ")", ";", "}", ")", "->", "then", "(", "function", "(", "Channel", "$", "channel", ")", "use", "(", "$", "bind", ")", "{", "foreach", "(", "$", "bind", "as", "$", "obj", ")", "{", "$", "obj", "->", "setChannel", "(", "$", "channel", ")", ";", "}", "return", "$", "channel", ";", "}", ")", ")", ";", "}" ]
Open a new channel and attribute it to given queues or exchanges. @param Queue[]|Exchange[] $bind
[ "Open", "a", "new", "channel", "and", "attribute", "it", "to", "given", "queues", "or", "exchanges", "." ]
16e2fa39daddb6cca70716b8895470c4691a6f9e
https://github.com/Rxnet/rabbitmq/blob/16e2fa39daddb6cca70716b8895470c4691a6f9e/Client.php#L64-L86
23,463
Rxnet/rabbitmq
Client.php
Client.consume
public function consume($queue, $prefetchCount = null, $prefetchSize = null, $consumerId = null): Observable { return $this->channel() ->do(function (Channel $channel) use ($prefetchCount, $prefetchSize) { $channel->qos($prefetchSize, $prefetchCount); }) ->flatMap( function (Channel $channel) use ($queue, $consumerId) { return $this->queue($queue, $channel) ->consume($consumerId); } ); }
php
public function consume($queue, $prefetchCount = null, $prefetchSize = null, $consumerId = null): Observable { return $this->channel() ->do(function (Channel $channel) use ($prefetchCount, $prefetchSize) { $channel->qos($prefetchSize, $prefetchCount); }) ->flatMap( function (Channel $channel) use ($queue, $consumerId) { return $this->queue($queue, $channel) ->consume($consumerId); } ); }
[ "public", "function", "consume", "(", "$", "queue", ",", "$", "prefetchCount", "=", "null", ",", "$", "prefetchSize", "=", "null", ",", "$", "consumerId", "=", "null", ")", ":", "Observable", "{", "return", "$", "this", "->", "channel", "(", ")", "->", "do", "(", "function", "(", "Channel", "$", "channel", ")", "use", "(", "$", "prefetchCount", ",", "$", "prefetchSize", ")", "{", "$", "channel", "->", "qos", "(", "$", "prefetchSize", ",", "$", "prefetchCount", ")", ";", "}", ")", "->", "flatMap", "(", "function", "(", "Channel", "$", "channel", ")", "use", "(", "$", "queue", ",", "$", "consumerId", ")", "{", "return", "$", "this", "->", "queue", "(", "$", "queue", ",", "$", "channel", ")", "->", "consume", "(", "$", "consumerId", ")", ";", "}", ")", ";", "}" ]
Consume given queue at.
[ "Consume", "given", "queue", "at", "." ]
16e2fa39daddb6cca70716b8895470c4691a6f9e
https://github.com/Rxnet/rabbitmq/blob/16e2fa39daddb6cca70716b8895470c4691a6f9e/Client.php#L91-L103
23,464
php-comp/lite-database
src/LitePdo.php
LitePdo.insertBatch
public function insertBatch(string $from, array $dataSet, array $options = []) { list($statement, $bindings) = $this->compileInsert($from, $dataSet, $options['columns'] ?? [], true); if (isset($options['returnSql'])) { return [$statement, $bindings]; } return $this->fetchAffected($statement, $bindings); }
php
public function insertBatch(string $from, array $dataSet, array $options = []) { list($statement, $bindings) = $this->compileInsert($from, $dataSet, $options['columns'] ?? [], true); if (isset($options['returnSql'])) { return [$statement, $bindings]; } return $this->fetchAffected($statement, $bindings); }
[ "public", "function", "insertBatch", "(", "string", "$", "from", ",", "array", "$", "dataSet", ",", "array", "$", "options", "=", "[", "]", ")", "{", "list", "(", "$", "statement", ",", "$", "bindings", ")", "=", "$", "this", "->", "compileInsert", "(", "$", "from", ",", "$", "dataSet", ",", "$", "options", "[", "'columns'", "]", "??", "[", "]", ",", "true", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'returnSql'", "]", ")", ")", "{", "return", "[", "$", "statement", ",", "$", "bindings", "]", ";", "}", "return", "$", "this", "->", "fetchAffected", "(", "$", "statement", ",", "$", "bindings", ")", ";", "}" ]
Run a statement for insert multi row @param string $from @param array $dataSet @param array $options - returnSql Will not be executed, just return the built SQL. - columns Setting the table columns to insert. @return int|array @throws \PDOException @throws \InvalidArgumentException
[ "Run", "a", "statement", "for", "insert", "multi", "row" ]
af5f73cb89e0e6cd24dd464f7a48fb5088eaafca
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L343-L352
23,465
php-comp/lite-database
src/LitePdo.php
LitePdo.update
public function update(string $from, $wheres, array $values, array $options = []) { list($where, $bindings) = DBHelper::handleConditions($wheres, $this); $options['update'] = $this->qn($from); $options['where'] = $where; $statement = $this->compileUpdate($values, $bindings, $options); if (isset($options['returnSql'])) { return [$statement, $bindings]; } return $this->fetchAffected($statement, $bindings); }
php
public function update(string $from, $wheres, array $values, array $options = []) { list($where, $bindings) = DBHelper::handleConditions($wheres, $this); $options['update'] = $this->qn($from); $options['where'] = $where; $statement = $this->compileUpdate($values, $bindings, $options); if (isset($options['returnSql'])) { return [$statement, $bindings]; } return $this->fetchAffected($statement, $bindings); }
[ "public", "function", "update", "(", "string", "$", "from", ",", "$", "wheres", ",", "array", "$", "values", ",", "array", "$", "options", "=", "[", "]", ")", "{", "list", "(", "$", "where", ",", "$", "bindings", ")", "=", "DBHelper", "::", "handleConditions", "(", "$", "wheres", ",", "$", "this", ")", ";", "$", "options", "[", "'update'", "]", "=", "$", "this", "->", "qn", "(", "$", "from", ")", ";", "$", "options", "[", "'where'", "]", "=", "$", "where", ";", "$", "statement", "=", "$", "this", "->", "compileUpdate", "(", "$", "values", ",", "$", "bindings", ",", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'returnSql'", "]", ")", ")", "{", "return", "[", "$", "statement", ",", "$", "bindings", "]", ";", "}", "return", "$", "this", "->", "fetchAffected", "(", "$", "statement", ",", "$", "bindings", ")", ";", "}" ]
Run a update statement @param string $from @param array|string $wheres @param array $values @param array $options @return int|array @throws \InvalidArgumentException
[ "Run", "a", "update", "statement" ]
af5f73cb89e0e6cd24dd464f7a48fb5088eaafca
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L363-L377
23,466
skmetaly/laravel-twitch-restful-api
src/API/Users.php
Users.authenticatedUser
public function authenticatedUser($token = null) { $token = $this->getToken($token); $user = $this->client->get('https://api.twitch.tv/kraken/user?oauth_token=' . $token); return $user->json(); }
php
public function authenticatedUser($token = null) { $token = $this->getToken($token); $user = $this->client->get('https://api.twitch.tv/kraken/user?oauth_token=' . $token); return $user->json(); }
[ "public", "function", "authenticatedUser", "(", "$", "token", "=", "null", ")", "{", "$", "token", "=", "$", "this", "->", "getToken", "(", "$", "token", ")", ";", "$", "user", "=", "$", "this", "->", "client", "->", "get", "(", "'https://api.twitch.tv/kraken/user?oauth_token='", ".", "$", "token", ")", ";", "return", "$", "user", "->", "json", "(", ")", ";", "}" ]
Returns a user object. Authenticated, required scope: user_read @param null $token @return json
[ "Returns", "a", "user", "object", "." ]
70c83e441deb411ade2e343ad5cb0339c90dc6c2
https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Users.php#L39-L46
23,467
surebert/surebert-framework
src/sb/Application/Debugger.php
Debugger.errorHandler
public static function errorHandler($code, $message, $file, $line) { if (error_reporting() === 0) { // This error code is not included in error_reporting return false; } throw new \sb\Exception($code, $message, $file, $line); }
php
public static function errorHandler($code, $message, $file, $line) { if (error_reporting() === 0) { // This error code is not included in error_reporting return false; } throw new \sb\Exception($code, $message, $file, $line); }
[ "public", "static", "function", "errorHandler", "(", "$", "code", ",", "$", "message", ",", "$", "file", ",", "$", "line", ")", "{", "if", "(", "error_reporting", "(", ")", "===", "0", ")", "{", "// This error code is not included in error_reporting", "return", "false", ";", "}", "throw", "new", "\\", "sb", "\\", "Exception", "(", "$", "code", ",", "$", "message", ",", "$", "file", ",", "$", "line", ")", ";", "}" ]
Converts errors into exceptions @param integer $code The error code @param string $message The error message @param string $file The file the error occurred in @param integer $line The line the error occurred on
[ "Converts", "errors", "into", "exceptions" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Application/Debugger.php#L29-L37
23,468
surebert/surebert-framework
src/sb/Application/Debugger.php
Debugger.exceptionHandler
public static function exceptionHandler($e) { $message = 'Code: ' . $e->getCode() . "\n" . 'Path: ' . \sb\Gateway::$request->path . "\n" . 'Message: ' . $e->getMessage() . "\n" . 'Location: ' . $e->getFile() . "\n" . 'Line: ' . $e->getLine() . "\n"; if(isset(\sb\Gateway::$request)){ $message .= 'Request: '.\sb\Gateway::$request->request."\n"; if(isset(\sb\Gateway::$request->method)){ $message .= 'Method: '.\sb\Gateway::$request->method."\n"; } if(count(\sb\Gateway::$request->get)){ $message .= 'Get: '.http_build_query(\sb\Gateway::$request->get) ."\n"; } } if (self::$show_trace) { $message .= "Trace: \n\t" . str_replace("\n", "\n\t", \print_r($e->getTrace(), 1)); } if (\method_exists("\App", "exception_handler")) { if (\App::exceptionHandler($e, $message) === false) { return false; } } if (\ini_get("display_errors") == true) { if (\sb\Gateway::$command_line) { \file_put_contents('php://stderr', "\n" . $message . "\n"); } else { echo '<pre style="background-color:red;padding:10px;color:#FFF;">' . $message . '</pre>'; } } if (!isset(\App::$logger)) { \App::$logger = new \sb\Logger\FileSystem(); } \App::$logger->exceptions($message); }
php
public static function exceptionHandler($e) { $message = 'Code: ' . $e->getCode() . "\n" . 'Path: ' . \sb\Gateway::$request->path . "\n" . 'Message: ' . $e->getMessage() . "\n" . 'Location: ' . $e->getFile() . "\n" . 'Line: ' . $e->getLine() . "\n"; if(isset(\sb\Gateway::$request)){ $message .= 'Request: '.\sb\Gateway::$request->request."\n"; if(isset(\sb\Gateway::$request->method)){ $message .= 'Method: '.\sb\Gateway::$request->method."\n"; } if(count(\sb\Gateway::$request->get)){ $message .= 'Get: '.http_build_query(\sb\Gateway::$request->get) ."\n"; } } if (self::$show_trace) { $message .= "Trace: \n\t" . str_replace("\n", "\n\t", \print_r($e->getTrace(), 1)); } if (\method_exists("\App", "exception_handler")) { if (\App::exceptionHandler($e, $message) === false) { return false; } } if (\ini_get("display_errors") == true) { if (\sb\Gateway::$command_line) { \file_put_contents('php://stderr', "\n" . $message . "\n"); } else { echo '<pre style="background-color:red;padding:10px;color:#FFF;">' . $message . '</pre>'; } } if (!isset(\App::$logger)) { \App::$logger = new \sb\Logger\FileSystem(); } \App::$logger->exceptions($message); }
[ "public", "static", "function", "exceptionHandler", "(", "$", "e", ")", "{", "$", "message", "=", "'Code: '", ".", "$", "e", "->", "getCode", "(", ")", ".", "\"\\n\"", ".", "'Path: '", ".", "\\", "sb", "\\", "Gateway", "::", "$", "request", "->", "path", ".", "\"\\n\"", ".", "'Message: '", ".", "$", "e", "->", "getMessage", "(", ")", ".", "\"\\n\"", ".", "'Location: '", ".", "$", "e", "->", "getFile", "(", ")", ".", "\"\\n\"", ".", "'Line: '", ".", "$", "e", "->", "getLine", "(", ")", ".", "\"\\n\"", ";", "if", "(", "isset", "(", "\\", "sb", "\\", "Gateway", "::", "$", "request", ")", ")", "{", "$", "message", ".=", "'Request: '", ".", "\\", "sb", "\\", "Gateway", "::", "$", "request", "->", "request", ".", "\"\\n\"", ";", "if", "(", "isset", "(", "\\", "sb", "\\", "Gateway", "::", "$", "request", "->", "method", ")", ")", "{", "$", "message", ".=", "'Method: '", ".", "\\", "sb", "\\", "Gateway", "::", "$", "request", "->", "method", ".", "\"\\n\"", ";", "}", "if", "(", "count", "(", "\\", "sb", "\\", "Gateway", "::", "$", "request", "->", "get", ")", ")", "{", "$", "message", ".=", "'Get: '", ".", "http_build_query", "(", "\\", "sb", "\\", "Gateway", "::", "$", "request", "->", "get", ")", ".", "\"\\n\"", ";", "}", "}", "if", "(", "self", "::", "$", "show_trace", ")", "{", "$", "message", ".=", "\"Trace: \\n\\t\"", ".", "str_replace", "(", "\"\\n\"", ",", "\"\\n\\t\"", ",", "\\", "print_r", "(", "$", "e", "->", "getTrace", "(", ")", ",", "1", ")", ")", ";", "}", "if", "(", "\\", "method_exists", "(", "\"\\App\"", ",", "\"exception_handler\"", ")", ")", "{", "if", "(", "\\", "App", "::", "exceptionHandler", "(", "$", "e", ",", "$", "message", ")", "===", "false", ")", "{", "return", "false", ";", "}", "}", "if", "(", "\\", "ini_get", "(", "\"display_errors\"", ")", "==", "true", ")", "{", "if", "(", "\\", "sb", "\\", "Gateway", "::", "$", "command_line", ")", "{", "\\", "file_put_contents", "(", "'php://stderr'", ",", "\"\\n\"", ".", "$", "message", ".", "\"\\n\"", ")", ";", "}", "else", "{", "echo", "'<pre style=\"background-color:red;padding:10px;color:#FFF;\">'", ".", "$", "message", ".", "'</pre>'", ";", "}", "}", "if", "(", "!", "isset", "(", "\\", "App", "::", "$", "logger", ")", ")", "{", "\\", "App", "::", "$", "logger", "=", "new", "\\", "sb", "\\", "Logger", "\\", "FileSystem", "(", ")", ";", "}", "\\", "App", "::", "$", "logger", "->", "exceptions", "(", "$", "message", ")", ";", "}" ]
Handles acceptions and turns them into strings @param Throwable|Exception $e A PHP exception or another class that implements the Throwable interface in PHP 7
[ "Handles", "acceptions", "and", "turns", "them", "into", "strings" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Application/Debugger.php#L43-L86
23,469
surebert/surebert-framework
src/sb/Application/Debugger.php
Debugger.shutdown
public static function shutdown() { if (\is_null($e = \error_get_last()) === false) { self::exceptionHandler(new \sb\Exception($e['type'], $e['message'], $e['file'], $e['line'])); } }
php
public static function shutdown() { if (\is_null($e = \error_get_last()) === false) { self::exceptionHandler(new \sb\Exception($e['type'], $e['message'], $e['file'], $e['line'])); } }
[ "public", "static", "function", "shutdown", "(", ")", "{", "if", "(", "\\", "is_null", "(", "$", "e", "=", "\\", "error_get_last", "(", ")", ")", "===", "false", ")", "{", "self", "::", "exceptionHandler", "(", "new", "\\", "sb", "\\", "Exception", "(", "$", "e", "[", "'type'", "]", ",", "$", "e", "[", "'message'", "]", ",", "$", "e", "[", "'file'", "]", ",", "$", "e", "[", "'line'", "]", ")", ")", ";", "}", "}" ]
Shutdown function catches additional parse errors
[ "Shutdown", "function", "catches", "additional", "parse", "errors" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Application/Debugger.php#L91-L96
23,470
surebert/surebert-framework
src/sb/Application/Debugger.php
Debugger.init
public static function init($error_reporting_level = E_ALL, $display_errors = true, $show_trace = true) { \error_reporting($error_reporting_level); \ini_set("display_errors", $display_errors ? true : false); self::$show_trace = $show_trace ? true : false; \set_error_handler('\sb\Application\Debugger::errorHandler'); \set_exception_handler('\sb\Application\Debugger::exceptionHandler'); \register_shutdown_function('\sb\Application\Debugger::shutdown'); }
php
public static function init($error_reporting_level = E_ALL, $display_errors = true, $show_trace = true) { \error_reporting($error_reporting_level); \ini_set("display_errors", $display_errors ? true : false); self::$show_trace = $show_trace ? true : false; \set_error_handler('\sb\Application\Debugger::errorHandler'); \set_exception_handler('\sb\Application\Debugger::exceptionHandler'); \register_shutdown_function('\sb\Application\Debugger::shutdown'); }
[ "public", "static", "function", "init", "(", "$", "error_reporting_level", "=", "E_ALL", ",", "$", "display_errors", "=", "true", ",", "$", "show_trace", "=", "true", ")", "{", "\\", "error_reporting", "(", "$", "error_reporting_level", ")", ";", "\\", "ini_set", "(", "\"display_errors\"", ",", "$", "display_errors", "?", "true", ":", "false", ")", ";", "self", "::", "$", "show_trace", "=", "$", "show_trace", "?", "true", ":", "false", ";", "\\", "set_error_handler", "(", "'\\sb\\Application\\Debugger::errorHandler'", ")", ";", "\\", "set_exception_handler", "(", "'\\sb\\Application\\Debugger::exceptionHandler'", ")", ";", "\\", "register_shutdown_function", "(", "'\\sb\\Application\\Debugger::shutdown'", ")", ";", "}" ]
Sets up debugger @param string $error_reporting_level The error level like @param boolean $display_errors Should errors be dumped to output @param type $show_trace Should trace message be shown
[ "Sets", "up", "debugger" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Application/Debugger.php#L103-L112
23,471
PayBreak/foundation
src/Data/Value.php
Value.availableTypes
public static function availableTypes() { return [ self::VALUE_INT, self::VALUE_STRING, self::VALUE_BOOL, self::VALUE_FLOAT, self::VALUE_DEFAULT, self::VALUE_NON_EXISTS, self::VALUE_EMPTY, self::VALUE_ARRAY, ]; }
php
public static function availableTypes() { return [ self::VALUE_INT, self::VALUE_STRING, self::VALUE_BOOL, self::VALUE_FLOAT, self::VALUE_DEFAULT, self::VALUE_NON_EXISTS, self::VALUE_EMPTY, self::VALUE_ARRAY, ]; }
[ "public", "static", "function", "availableTypes", "(", ")", "{", "return", "[", "self", "::", "VALUE_INT", ",", "self", "::", "VALUE_STRING", ",", "self", "::", "VALUE_BOOL", ",", "self", "::", "VALUE_FLOAT", ",", "self", "::", "VALUE_DEFAULT", ",", "self", "::", "VALUE_NON_EXISTS", ",", "self", "::", "VALUE_EMPTY", ",", "self", "::", "VALUE_ARRAY", ",", "]", ";", "}" ]
Get Available Value Types @author WN @return array
[ "Get", "Available", "Value", "Types" ]
3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4
https://github.com/PayBreak/foundation/blob/3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4/src/Data/Value.php#L56-L68
23,472
PayBreak/foundation
src/Data/Value.php
Value.availableDefaultValues
public static function availableDefaultValues() { return [ self::DEFAULT_NULL, self::DEFAULT_OUT_OF_BOUNDS, self::DEFAULT_NOT_DERIVABLE, self::DEFAULT_NOT_GIVEN, self::DEFAULT_NOT_ASKED, self::DEFAULT_NOT_PERMITTED, ]; }
php
public static function availableDefaultValues() { return [ self::DEFAULT_NULL, self::DEFAULT_OUT_OF_BOUNDS, self::DEFAULT_NOT_DERIVABLE, self::DEFAULT_NOT_GIVEN, self::DEFAULT_NOT_ASKED, self::DEFAULT_NOT_PERMITTED, ]; }
[ "public", "static", "function", "availableDefaultValues", "(", ")", "{", "return", "[", "self", "::", "DEFAULT_NULL", ",", "self", "::", "DEFAULT_OUT_OF_BOUNDS", ",", "self", "::", "DEFAULT_NOT_DERIVABLE", ",", "self", "::", "DEFAULT_NOT_GIVEN", ",", "self", "::", "DEFAULT_NOT_ASKED", ",", "self", "::", "DEFAULT_NOT_PERMITTED", ",", "]", ";", "}" ]
Get Available Default Values @author WN @return array
[ "Get", "Available", "Default", "Values" ]
3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4
https://github.com/PayBreak/foundation/blob/3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4/src/Data/Value.php#L76-L86
23,473
mainio/c5pkg_symfony_forms
src/Mainio/C5/Symfony/Form/Extension/Concrete5/DataTransformer/UserToIntegerTransformer.php
UserToIntegerTransformer.transform
public function transform($value) { if ($value === null || $value == '') { return null; } if (!($value instanceof User)) { throw new TransformationFailedException('Expected an instance of a concrete5 user object.'); } return intval($value->getUserID()); }
php
public function transform($value) { if ($value === null || $value == '') { return null; } if (!($value instanceof User)) { throw new TransformationFailedException('Expected an instance of a concrete5 user object.'); } return intval($value->getUserID()); }
[ "public", "function", "transform", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", "||", "$", "value", "==", "''", ")", "{", "return", "null", ";", "}", "if", "(", "!", "(", "$", "value", "instanceof", "User", ")", ")", "{", "throw", "new", "TransformationFailedException", "(", "'Expected an instance of a concrete5 user object.'", ")", ";", "}", "return", "intval", "(", "$", "value", "->", "getUserID", "(", ")", ")", ";", "}" ]
Converts a concrete5 user object to an integer. @param \Concrete\Core\User\User $value The user object value @return int The integer value @throws TransformationFailedException If the given value is not an instance of Concrete\Core\User\User.
[ "Converts", "a", "concrete5", "user", "object", "to", "an", "integer", "." ]
41a93c293d986574ec5cade8a7c8700e083dbaaa
https://github.com/mainio/c5pkg_symfony_forms/blob/41a93c293d986574ec5cade8a7c8700e083dbaaa/src/Mainio/C5/Symfony/Form/Extension/Concrete5/DataTransformer/UserToIntegerTransformer.php#L33-L42
23,474
superjimpupcake/Pupcake
src/Pupcake/Plugin.php
Plugin.help
public function help($event_name, $callback) { if (!isset($this->event_helpers[$event_name])) { $this->event_helpers[$event_name] = $callback; } }
php
public function help($event_name, $callback) { if (!isset($this->event_helpers[$event_name])) { $this->event_helpers[$event_name] = $callback; } }
[ "public", "function", "help", "(", "$", "event_name", ",", "$", "callback", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "event_helpers", "[", "$", "event_name", "]", ")", ")", "{", "$", "this", "->", "event_helpers", "[", "$", "event_name", "]", "=", "$", "callback", ";", "}", "}" ]
add a helper callback to an event
[ "add", "a", "helper", "callback", "to", "an", "event" ]
2f962818646e4e1d65f5d008eeb953cb41ebb3e0
https://github.com/superjimpupcake/Pupcake/blob/2f962818646e4e1d65f5d008eeb953cb41ebb3e0/src/Pupcake/Plugin.php#L46-L52
23,475
old-town/workflow-designer-server
src/Listener/SendApiProblemResponseListener.php
SendApiProblemResponseListener.sendContent
public function sendContent(SendResponseEvent $e) { $response = $e->getResponse(); if (!$response instanceof ApiProblemResponse) { return $this; } $response->getApiProblem()->setDetailIncludesStackTrace($this->displayExceptions()); /** @var Request $request */ $request = $this->getMvcEvent()->getRequest(); /** @var Accept $accept */ $accept = $request->getHeader('Accept'); if ($accept instanceof Accept && $accept->hasMediaType('text/xml')) { $arrayResponse = $response->getApiProblem()->toArray(); $xmlWriter = new XmlWriter(); if (array_key_exists('trace', $arrayResponse)) { array_walk($arrayResponse['trace'], function (&$item) { unset($item['args']); }); } if (array_key_exists('exception_stack', $arrayResponse)) { array_walk($arrayResponse['exception_stack'], function (&$item) { array_walk($item['trace'], function (&$trace) { unset($trace['args']); }); }); } $output = $xmlWriter->processConfig($arrayResponse); echo $output; $e->setContentSent(); return $this; } return parent::sendHeaders($e); }
php
public function sendContent(SendResponseEvent $e) { $response = $e->getResponse(); if (!$response instanceof ApiProblemResponse) { return $this; } $response->getApiProblem()->setDetailIncludesStackTrace($this->displayExceptions()); /** @var Request $request */ $request = $this->getMvcEvent()->getRequest(); /** @var Accept $accept */ $accept = $request->getHeader('Accept'); if ($accept instanceof Accept && $accept->hasMediaType('text/xml')) { $arrayResponse = $response->getApiProblem()->toArray(); $xmlWriter = new XmlWriter(); if (array_key_exists('trace', $arrayResponse)) { array_walk($arrayResponse['trace'], function (&$item) { unset($item['args']); }); } if (array_key_exists('exception_stack', $arrayResponse)) { array_walk($arrayResponse['exception_stack'], function (&$item) { array_walk($item['trace'], function (&$trace) { unset($trace['args']); }); }); } $output = $xmlWriter->processConfig($arrayResponse); echo $output; $e->setContentSent(); return $this; } return parent::sendHeaders($e); }
[ "public", "function", "sendContent", "(", "SendResponseEvent", "$", "e", ")", "{", "$", "response", "=", "$", "e", "->", "getResponse", "(", ")", ";", "if", "(", "!", "$", "response", "instanceof", "ApiProblemResponse", ")", "{", "return", "$", "this", ";", "}", "$", "response", "->", "getApiProblem", "(", ")", "->", "setDetailIncludesStackTrace", "(", "$", "this", "->", "displayExceptions", "(", ")", ")", ";", "/** @var Request $request */", "$", "request", "=", "$", "this", "->", "getMvcEvent", "(", ")", "->", "getRequest", "(", ")", ";", "/** @var Accept $accept */", "$", "accept", "=", "$", "request", "->", "getHeader", "(", "'Accept'", ")", ";", "if", "(", "$", "accept", "instanceof", "Accept", "&&", "$", "accept", "->", "hasMediaType", "(", "'text/xml'", ")", ")", "{", "$", "arrayResponse", "=", "$", "response", "->", "getApiProblem", "(", ")", "->", "toArray", "(", ")", ";", "$", "xmlWriter", "=", "new", "XmlWriter", "(", ")", ";", "if", "(", "array_key_exists", "(", "'trace'", ",", "$", "arrayResponse", ")", ")", "{", "array_walk", "(", "$", "arrayResponse", "[", "'trace'", "]", ",", "function", "(", "&", "$", "item", ")", "{", "unset", "(", "$", "item", "[", "'args'", "]", ")", ";", "}", ")", ";", "}", "if", "(", "array_key_exists", "(", "'exception_stack'", ",", "$", "arrayResponse", ")", ")", "{", "array_walk", "(", "$", "arrayResponse", "[", "'exception_stack'", "]", ",", "function", "(", "&", "$", "item", ")", "{", "array_walk", "(", "$", "item", "[", "'trace'", "]", ",", "function", "(", "&", "$", "trace", ")", "{", "unset", "(", "$", "trace", "[", "'args'", "]", ")", ";", "}", ")", ";", "}", ")", ";", "}", "$", "output", "=", "$", "xmlWriter", "->", "processConfig", "(", "$", "arrayResponse", ")", ";", "echo", "$", "output", ";", "$", "e", "->", "setContentSent", "(", ")", ";", "return", "$", "this", ";", "}", "return", "parent", "::", "sendHeaders", "(", "$", "e", ")", ";", "}" ]
Send the response content Sets the composed ApiProblem's flag for including the stack trace in the detail based on the display exceptions flag, and then sends content. @param SendResponseEvent $e @return self @throws \Zend\Config\Exception\RuntimeException
[ "Send", "the", "response", "content" ]
6389c5a515861cc8e0b769f1ca7be12c6b78c611
https://github.com/old-town/workflow-designer-server/blob/6389c5a515861cc8e0b769f1ca7be12c6b78c611/src/Listener/SendApiProblemResponseListener.php#L63-L102
23,476
old-town/workflow-designer-server
src/Listener/SendApiProblemResponseListener.php
SendApiProblemResponseListener.sendHeaders
public function sendHeaders(SendResponseEvent $e) { $response = $e->getResponse(); if (!$response instanceof ApiProblemResponse) { return $this; } /** @var Request $request */ $request = $this->getMvcEvent()->getRequest(); /** @var Accept $accept */ $accept = $request->getHeader('Accept'); if ($accept instanceof Accept && $accept->hasMediaType('text/xml')) { $headers = $response->getHeaders(); if ($headers->has('content-type')) { $contentTypeHeader = $headers->get('content-type'); $headers->removeHeader($contentTypeHeader); } $headers->addHeaderLine('content-type', 'text/xml'); if ($this->applicationResponse instanceof HttpResponse) { $this->mergeHeaders($this->applicationResponse, $response); } } return parent::sendHeaders($e); }
php
public function sendHeaders(SendResponseEvent $e) { $response = $e->getResponse(); if (!$response instanceof ApiProblemResponse) { return $this; } /** @var Request $request */ $request = $this->getMvcEvent()->getRequest(); /** @var Accept $accept */ $accept = $request->getHeader('Accept'); if ($accept instanceof Accept && $accept->hasMediaType('text/xml')) { $headers = $response->getHeaders(); if ($headers->has('content-type')) { $contentTypeHeader = $headers->get('content-type'); $headers->removeHeader($contentTypeHeader); } $headers->addHeaderLine('content-type', 'text/xml'); if ($this->applicationResponse instanceof HttpResponse) { $this->mergeHeaders($this->applicationResponse, $response); } } return parent::sendHeaders($e); }
[ "public", "function", "sendHeaders", "(", "SendResponseEvent", "$", "e", ")", "{", "$", "response", "=", "$", "e", "->", "getResponse", "(", ")", ";", "if", "(", "!", "$", "response", "instanceof", "ApiProblemResponse", ")", "{", "return", "$", "this", ";", "}", "/** @var Request $request */", "$", "request", "=", "$", "this", "->", "getMvcEvent", "(", ")", "->", "getRequest", "(", ")", ";", "/** @var Accept $accept */", "$", "accept", "=", "$", "request", "->", "getHeader", "(", "'Accept'", ")", ";", "if", "(", "$", "accept", "instanceof", "Accept", "&&", "$", "accept", "->", "hasMediaType", "(", "'text/xml'", ")", ")", "{", "$", "headers", "=", "$", "response", "->", "getHeaders", "(", ")", ";", "if", "(", "$", "headers", "->", "has", "(", "'content-type'", ")", ")", "{", "$", "contentTypeHeader", "=", "$", "headers", "->", "get", "(", "'content-type'", ")", ";", "$", "headers", "->", "removeHeader", "(", "$", "contentTypeHeader", ")", ";", "}", "$", "headers", "->", "addHeaderLine", "(", "'content-type'", ",", "'text/xml'", ")", ";", "if", "(", "$", "this", "->", "applicationResponse", "instanceof", "HttpResponse", ")", "{", "$", "this", "->", "mergeHeaders", "(", "$", "this", "->", "applicationResponse", ",", "$", "response", ")", ";", "}", "}", "return", "parent", "::", "sendHeaders", "(", "$", "e", ")", ";", "}" ]
Send HTTP response headers If an application response is composed, and is an HTTP response, merges its headers with the ApiProblemResponse headers prior to sending them. @param SendResponseEvent $e @return self @throws \Zend\Http\Exception\InvalidArgumentException
[ "Send", "HTTP", "response", "headers" ]
6389c5a515861cc8e0b769f1ca7be12c6b78c611
https://github.com/old-town/workflow-designer-server/blob/6389c5a515861cc8e0b769f1ca7be12c6b78c611/src/Listener/SendApiProblemResponseListener.php#L115-L143
23,477
ellipsephp/session-validation
src/ValidateSessionMiddleware.php
ValidateSessionMiddleware.process
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { // Get a valid signature. $signature = ($this->signature)($request); if (! is_array($signature)) { throw new OwnershipSignatureTypeException($signature); } // Invalidate the session when signature and session does not match. $metadata = $_SESSION[self::METADATA_KEY] ?? []; if (! $this->compare($signature, $metadata)) { $_SESSION = []; session_regenerate_id(); } // Process the request and save the current signature. $response = $handler->handle($request); $_SESSION[self::METADATA_KEY] = $signature; return $response; }
php
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { // Get a valid signature. $signature = ($this->signature)($request); if (! is_array($signature)) { throw new OwnershipSignatureTypeException($signature); } // Invalidate the session when signature and session does not match. $metadata = $_SESSION[self::METADATA_KEY] ?? []; if (! $this->compare($signature, $metadata)) { $_SESSION = []; session_regenerate_id(); } // Process the request and save the current signature. $response = $handler->handle($request); $_SESSION[self::METADATA_KEY] = $signature; return $response; }
[ "public", "function", "process", "(", "ServerRequestInterface", "$", "request", ",", "RequestHandlerInterface", "$", "handler", ")", ":", "ResponseInterface", "{", "// Get a valid signature.", "$", "signature", "=", "(", "$", "this", "->", "signature", ")", "(", "$", "request", ")", ";", "if", "(", "!", "is_array", "(", "$", "signature", ")", ")", "{", "throw", "new", "OwnershipSignatureTypeException", "(", "$", "signature", ")", ";", "}", "// Invalidate the session when signature and session does not match.", "$", "metadata", "=", "$", "_SESSION", "[", "self", "::", "METADATA_KEY", "]", "??", "[", "]", ";", "if", "(", "!", "$", "this", "->", "compare", "(", "$", "signature", ",", "$", "metadata", ")", ")", "{", "$", "_SESSION", "=", "[", "]", ";", "session_regenerate_id", "(", ")", ";", "}", "// Process the request and save the current signature.", "$", "response", "=", "$", "handler", "->", "handle", "(", "$", "request", ")", ";", "$", "_SESSION", "[", "self", "::", "METADATA_KEY", "]", "=", "$", "signature", ";", "return", "$", "response", ";", "}" ]
Build a signature and compare it to the ownership metadata stored in session. Invalidate the session when any key does not match. Process the request and save the current signature in session. @param \Psr\Http\Message\ServerRequestInterface $request @param \Psr\Http\Server\RequestHandlerInterface $handler @return \Psr\Http\Message\ResponseInterface
[ "Build", "a", "signature", "and", "compare", "it", "to", "the", "ownership", "metadata", "stored", "in", "session", ".", "Invalidate", "the", "session", "when", "any", "key", "does", "not", "match", ".", "Process", "the", "request", "and", "save", "the", "current", "signature", "in", "session", "." ]
c5d8bd0aed23abe0933f649b9e20ff48ab9efbc9
https://github.com/ellipsephp/session-validation/blob/c5d8bd0aed23abe0933f649b9e20ff48ab9efbc9/src/ValidateSessionMiddleware.php#L47-L74
23,478
ellipsephp/session-validation
src/ValidateSessionMiddleware.php
ValidateSessionMiddleware.compare
private function compare(array $signature, array $metadata): bool { foreach ($signature as $key => $v1) { $v2 = $metadata[$key] ?? null; if (! is_null($v2) && $v1 !== $v2) return false; } return true; }
php
private function compare(array $signature, array $metadata): bool { foreach ($signature as $key => $v1) { $v2 = $metadata[$key] ?? null; if (! is_null($v2) && $v1 !== $v2) return false; } return true; }
[ "private", "function", "compare", "(", "array", "$", "signature", ",", "array", "$", "metadata", ")", ":", "bool", "{", "foreach", "(", "$", "signature", "as", "$", "key", "=>", "$", "v1", ")", "{", "$", "v2", "=", "$", "metadata", "[", "$", "key", "]", "??", "null", ";", "if", "(", "!", "is_null", "(", "$", "v2", ")", "&&", "$", "v1", "!==", "$", "v2", ")", "return", "false", ";", "}", "return", "true", ";", "}" ]
Return whether all keys of the given signature match the given metadata. @param array $signature @param array $metadata @return bool
[ "Return", "whether", "all", "keys", "of", "the", "given", "signature", "match", "the", "given", "metadata", "." ]
c5d8bd0aed23abe0933f649b9e20ff48ab9efbc9
https://github.com/ellipsephp/session-validation/blob/c5d8bd0aed23abe0933f649b9e20ff48ab9efbc9/src/ValidateSessionMiddleware.php#L83-L94
23,479
heidelpay/PhpDoc
src/phpDocumentor/Application.php
Application.configureLogger
public function configureLogger($logger, $level, $logPath = null) { /** @var Logger $monolog */ $monolog = $logger; switch ($level) { case 'emergency': case 'emerg': $level = Logger::EMERGENCY; break; case 'alert': $level = Logger::ALERT; break; case 'critical': case 'crit': $level = Logger::CRITICAL; break; case 'error': case 'err': $level = Logger::ERROR; break; case 'warning': case 'warn': $level = Logger::WARNING; break; case 'notice': $level = Logger::NOTICE; break; case 'info': $level = Logger::INFO; break; case 'debug': $level = Logger::DEBUG; break; } $this['monolog.level'] = $level; if ($logPath) { $logPath = str_replace( array('{APP_ROOT}', '{DATE}'), array(realpath(__DIR__.'/../..'), $this['kernel.timer.start']), $logPath ); $this['monolog.logfile'] = $logPath; } // remove all handlers from the stack try { while ($monolog->popHandler()) { } } catch (\LogicException $e) { // popHandler throws an exception when you try to pop the empty stack; to us this is not an // error but an indication that the handler stack is empty. } if ($level === 'quiet') { $monolog->pushHandler(new NullHandler()); return; } // set our new handlers if ($logPath) { $monolog->pushHandler(new StreamHandler($logPath, $level)); } else { $monolog->pushHandler(new StreamHandler('php://stdout', $level)); } }
php
public function configureLogger($logger, $level, $logPath = null) { /** @var Logger $monolog */ $monolog = $logger; switch ($level) { case 'emergency': case 'emerg': $level = Logger::EMERGENCY; break; case 'alert': $level = Logger::ALERT; break; case 'critical': case 'crit': $level = Logger::CRITICAL; break; case 'error': case 'err': $level = Logger::ERROR; break; case 'warning': case 'warn': $level = Logger::WARNING; break; case 'notice': $level = Logger::NOTICE; break; case 'info': $level = Logger::INFO; break; case 'debug': $level = Logger::DEBUG; break; } $this['monolog.level'] = $level; if ($logPath) { $logPath = str_replace( array('{APP_ROOT}', '{DATE}'), array(realpath(__DIR__.'/../..'), $this['kernel.timer.start']), $logPath ); $this['monolog.logfile'] = $logPath; } // remove all handlers from the stack try { while ($monolog->popHandler()) { } } catch (\LogicException $e) { // popHandler throws an exception when you try to pop the empty stack; to us this is not an // error but an indication that the handler stack is empty. } if ($level === 'quiet') { $monolog->pushHandler(new NullHandler()); return; } // set our new handlers if ($logPath) { $monolog->pushHandler(new StreamHandler($logPath, $level)); } else { $monolog->pushHandler(new StreamHandler('php://stdout', $level)); } }
[ "public", "function", "configureLogger", "(", "$", "logger", ",", "$", "level", ",", "$", "logPath", "=", "null", ")", "{", "/** @var Logger $monolog */", "$", "monolog", "=", "$", "logger", ";", "switch", "(", "$", "level", ")", "{", "case", "'emergency'", ":", "case", "'emerg'", ":", "$", "level", "=", "Logger", "::", "EMERGENCY", ";", "break", ";", "case", "'alert'", ":", "$", "level", "=", "Logger", "::", "ALERT", ";", "break", ";", "case", "'critical'", ":", "case", "'crit'", ":", "$", "level", "=", "Logger", "::", "CRITICAL", ";", "break", ";", "case", "'error'", ":", "case", "'err'", ":", "$", "level", "=", "Logger", "::", "ERROR", ";", "break", ";", "case", "'warning'", ":", "case", "'warn'", ":", "$", "level", "=", "Logger", "::", "WARNING", ";", "break", ";", "case", "'notice'", ":", "$", "level", "=", "Logger", "::", "NOTICE", ";", "break", ";", "case", "'info'", ":", "$", "level", "=", "Logger", "::", "INFO", ";", "break", ";", "case", "'debug'", ":", "$", "level", "=", "Logger", "::", "DEBUG", ";", "break", ";", "}", "$", "this", "[", "'monolog.level'", "]", "=", "$", "level", ";", "if", "(", "$", "logPath", ")", "{", "$", "logPath", "=", "str_replace", "(", "array", "(", "'{APP_ROOT}'", ",", "'{DATE}'", ")", ",", "array", "(", "realpath", "(", "__DIR__", ".", "'/../..'", ")", ",", "$", "this", "[", "'kernel.timer.start'", "]", ")", ",", "$", "logPath", ")", ";", "$", "this", "[", "'monolog.logfile'", "]", "=", "$", "logPath", ";", "}", "// remove all handlers from the stack", "try", "{", "while", "(", "$", "monolog", "->", "popHandler", "(", ")", ")", "{", "}", "}", "catch", "(", "\\", "LogicException", "$", "e", ")", "{", "// popHandler throws an exception when you try to pop the empty stack; to us this is not an", "// error but an indication that the handler stack is empty.", "}", "if", "(", "$", "level", "===", "'quiet'", ")", "{", "$", "monolog", "->", "pushHandler", "(", "new", "NullHandler", "(", ")", ")", ";", "return", ";", "}", "// set our new handlers", "if", "(", "$", "logPath", ")", "{", "$", "monolog", "->", "pushHandler", "(", "new", "StreamHandler", "(", "$", "logPath", ",", "$", "level", ")", ")", ";", "}", "else", "{", "$", "monolog", "->", "pushHandler", "(", "new", "StreamHandler", "(", "'php://stdout'", ",", "$", "level", ")", ")", ";", "}", "}" ]
Removes all logging handlers and replaces them with handlers that can write to the given logPath and level. @param Logger $logger The logger instance that needs to be configured. @param integer $level The minimum level that will be written to the normal logfile; matches one of the constants in {@see \Monolog\Logger}. @param string $logPath The full path where the normal log file needs to be written. @return void
[ "Removes", "all", "logging", "handlers", "and", "replaces", "them", "with", "handlers", "that", "can", "write", "to", "the", "given", "logPath", "and", "level", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Application.php#L94-L161
23,480
heidelpay/PhpDoc
src/phpDocumentor/Application.php
Application.addLogging
protected function addLogging() { $this->register( new MonologServiceProvider(), array( 'monolog.name' => 'phpDocumentor', 'monolog.logfile' => sys_get_temp_dir() . '/phpdoc.log', 'monolog.debugfile' => sys_get_temp_dir() . '/phpdoc.debug.log', 'monolog.level' => Logger::INFO, ) ); $app = $this; /** @var Configuration $configuration */ $configuration = $this['config']; $this['monolog.configure'] = $this->protect( function ($log) use ($app, $configuration) { $paths = $configuration->getLogging()->getPaths(); $logLevel = $configuration->getLogging()->getLevel(); $app->configureLogger($log, $logLevel, $paths['default'], $paths['errors']); } ); $this->extend( 'console', function (ConsoleApplication $console) use ($configuration) { $console->getHelperSet()->set(new LoggerHelper()); $console->getHelperSet()->set(new ConfigurationHelper($configuration)); return $console; } ); ErrorHandler::register($this['monolog']); }
php
protected function addLogging() { $this->register( new MonologServiceProvider(), array( 'monolog.name' => 'phpDocumentor', 'monolog.logfile' => sys_get_temp_dir() . '/phpdoc.log', 'monolog.debugfile' => sys_get_temp_dir() . '/phpdoc.debug.log', 'monolog.level' => Logger::INFO, ) ); $app = $this; /** @var Configuration $configuration */ $configuration = $this['config']; $this['monolog.configure'] = $this->protect( function ($log) use ($app, $configuration) { $paths = $configuration->getLogging()->getPaths(); $logLevel = $configuration->getLogging()->getLevel(); $app->configureLogger($log, $logLevel, $paths['default'], $paths['errors']); } ); $this->extend( 'console', function (ConsoleApplication $console) use ($configuration) { $console->getHelperSet()->set(new LoggerHelper()); $console->getHelperSet()->set(new ConfigurationHelper($configuration)); return $console; } ); ErrorHandler::register($this['monolog']); }
[ "protected", "function", "addLogging", "(", ")", "{", "$", "this", "->", "register", "(", "new", "MonologServiceProvider", "(", ")", ",", "array", "(", "'monolog.name'", "=>", "'phpDocumentor'", ",", "'monolog.logfile'", "=>", "sys_get_temp_dir", "(", ")", ".", "'/phpdoc.log'", ",", "'monolog.debugfile'", "=>", "sys_get_temp_dir", "(", ")", ".", "'/phpdoc.debug.log'", ",", "'monolog.level'", "=>", "Logger", "::", "INFO", ",", ")", ")", ";", "$", "app", "=", "$", "this", ";", "/** @var Configuration $configuration */", "$", "configuration", "=", "$", "this", "[", "'config'", "]", ";", "$", "this", "[", "'monolog.configure'", "]", "=", "$", "this", "->", "protect", "(", "function", "(", "$", "log", ")", "use", "(", "$", "app", ",", "$", "configuration", ")", "{", "$", "paths", "=", "$", "configuration", "->", "getLogging", "(", ")", "->", "getPaths", "(", ")", ";", "$", "logLevel", "=", "$", "configuration", "->", "getLogging", "(", ")", "->", "getLevel", "(", ")", ";", "$", "app", "->", "configureLogger", "(", "$", "log", ",", "$", "logLevel", ",", "$", "paths", "[", "'default'", "]", ",", "$", "paths", "[", "'errors'", "]", ")", ";", "}", ")", ";", "$", "this", "->", "extend", "(", "'console'", ",", "function", "(", "ConsoleApplication", "$", "console", ")", "use", "(", "$", "configuration", ")", "{", "$", "console", "->", "getHelperSet", "(", ")", "->", "set", "(", "new", "LoggerHelper", "(", ")", ")", ";", "$", "console", "->", "getHelperSet", "(", ")", "->", "set", "(", "new", "ConfigurationHelper", "(", "$", "configuration", ")", ")", ";", "return", "$", "console", ";", "}", ")", ";", "ErrorHandler", "::", "register", "(", "$", "this", "[", "'monolog'", "]", ")", ";", "}" ]
Adds a logging provider to the container of phpDocumentor. @return void
[ "Adds", "a", "logging", "provider", "to", "the", "container", "of", "phpDocumentor", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Application.php#L240-L275
23,481
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/helper.php
ezcDbSchemaOracleHelper.generateSuffixedIdentName
public static function generateSuffixedIdentName( array $identNames, $suffix ) { $ident = implode( "_", $identNames ) . "_" . $suffix; $i = 0; $last = -1; while ( strlen( $ident ) > self::IDENTIFIER_MAX_LENGTH ) { if ( strlen( $identNames[$i] ) > 1 || $last == $i ) { $identNames[$i] = substr( $identNames[$i], 0, strlen( $identNames[$i] ) - 1 ); $last = $i; } $i = ( $i + 1 ) % count( $identNames ); $ident = implode( "_", $identNames ) . "_" . $suffix; } return $ident; }
php
public static function generateSuffixedIdentName( array $identNames, $suffix ) { $ident = implode( "_", $identNames ) . "_" . $suffix; $i = 0; $last = -1; while ( strlen( $ident ) > self::IDENTIFIER_MAX_LENGTH ) { if ( strlen( $identNames[$i] ) > 1 || $last == $i ) { $identNames[$i] = substr( $identNames[$i], 0, strlen( $identNames[$i] ) - 1 ); $last = $i; } $i = ( $i + 1 ) % count( $identNames ); $ident = implode( "_", $identNames ) . "_" . $suffix; } return $ident; }
[ "public", "static", "function", "generateSuffixedIdentName", "(", "array", "$", "identNames", ",", "$", "suffix", ")", "{", "$", "ident", "=", "implode", "(", "\"_\"", ",", "$", "identNames", ")", ".", "\"_\"", ".", "$", "suffix", ";", "$", "i", "=", "0", ";", "$", "last", "=", "-", "1", ";", "while", "(", "strlen", "(", "$", "ident", ")", ">", "self", "::", "IDENTIFIER_MAX_LENGTH", ")", "{", "if", "(", "strlen", "(", "$", "identNames", "[", "$", "i", "]", ")", ">", "1", "||", "$", "last", "==", "$", "i", ")", "{", "$", "identNames", "[", "$", "i", "]", "=", "substr", "(", "$", "identNames", "[", "$", "i", "]", ",", "0", ",", "strlen", "(", "$", "identNames", "[", "$", "i", "]", ")", "-", "1", ")", ";", "$", "last", "=", "$", "i", ";", "}", "$", "i", "=", "(", "$", "i", "+", "1", ")", "%", "count", "(", "$", "identNames", ")", ";", "$", "ident", "=", "implode", "(", "\"_\"", ",", "$", "identNames", ")", ".", "\"_\"", ".", "$", "suffix", ";", "}", "return", "$", "ident", ";", "}" ]
Generate single identifier name for constraints for example obeying oracle 30 chars ident restriction. @param array $identNames @param string $suffix @return string
[ "Generate", "single", "identifier", "name", "for", "constraints", "for", "example", "obeying", "oracle", "30", "chars", "ident", "restriction", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/helper.php#L46-L63
23,482
mothership-ec/composer
src/Composer/DependencyResolver/RuleSetGenerator.php
RuleSetGenerator.createInstallOneOfRule
protected function createInstallOneOfRule(array $packages, $reason, $job) { $literals = array(); foreach ($packages as $package) { $literals[] = $package->id; } return new Rule($literals, $reason, $job['packageName'], $job); }
php
protected function createInstallOneOfRule(array $packages, $reason, $job) { $literals = array(); foreach ($packages as $package) { $literals[] = $package->id; } return new Rule($literals, $reason, $job['packageName'], $job); }
[ "protected", "function", "createInstallOneOfRule", "(", "array", "$", "packages", ",", "$", "reason", ",", "$", "job", ")", "{", "$", "literals", "=", "array", "(", ")", ";", "foreach", "(", "$", "packages", "as", "$", "package", ")", "{", "$", "literals", "[", "]", "=", "$", "package", "->", "id", ";", "}", "return", "new", "Rule", "(", "$", "literals", ",", "$", "reason", ",", "$", "job", "[", "'packageName'", "]", ",", "$", "job", ")", ";", "}" ]
Creates a rule to install at least one of a set of packages The rule is (A|B|C) with A, B and C different packages. If the given set of packages is empty an impossible rule is generated. @param array $packages The set of packages to choose from @param int $reason A RULE_* constant describing the reason for generating this rule @param array $job The job this rule was created from @return Rule The generated rule
[ "Creates", "a", "rule", "to", "install", "at", "least", "one", "of", "a", "set", "of", "packages" ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/DependencyResolver/RuleSetGenerator.php#L79-L87
23,483
mothership-ec/composer
src/Composer/DependencyResolver/RuleSetGenerator.php
RuleSetGenerator.createRemoveRule
protected function createRemoveRule(PackageInterface $package, $reason, $job) { return new Rule(array(-$package->id), $reason, $job['packageName'], $job); }
php
protected function createRemoveRule(PackageInterface $package, $reason, $job) { return new Rule(array(-$package->id), $reason, $job['packageName'], $job); }
[ "protected", "function", "createRemoveRule", "(", "PackageInterface", "$", "package", ",", "$", "reason", ",", "$", "job", ")", "{", "return", "new", "Rule", "(", "array", "(", "-", "$", "package", "->", "id", ")", ",", "$", "reason", ",", "$", "job", "[", "'packageName'", "]", ",", "$", "job", ")", ";", "}" ]
Creates a rule to remove a package The rule for a package A is (-A). @param PackageInterface $package The package to be removed @param int $reason A RULE_* constant describing the reason for generating this rule @param array $job The job this rule was created from @return Rule The generated rule
[ "Creates", "a", "rule", "to", "remove", "a", "package" ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/DependencyResolver/RuleSetGenerator.php#L100-L103
23,484
mothership-ec/composer
src/Composer/DependencyResolver/RuleSetGenerator.php
RuleSetGenerator.createConflictRule
protected function createConflictRule(PackageInterface $issuer, PackageInterface $provider, $reason, $reasonData = null) { // ignore self conflict if ($issuer === $provider) { return null; } return new Rule(array(-$issuer->id, -$provider->id), $reason, $reasonData); }
php
protected function createConflictRule(PackageInterface $issuer, PackageInterface $provider, $reason, $reasonData = null) { // ignore self conflict if ($issuer === $provider) { return null; } return new Rule(array(-$issuer->id, -$provider->id), $reason, $reasonData); }
[ "protected", "function", "createConflictRule", "(", "PackageInterface", "$", "issuer", ",", "PackageInterface", "$", "provider", ",", "$", "reason", ",", "$", "reasonData", "=", "null", ")", "{", "// ignore self conflict", "if", "(", "$", "issuer", "===", "$", "provider", ")", "{", "return", "null", ";", "}", "return", "new", "Rule", "(", "array", "(", "-", "$", "issuer", "->", "id", ",", "-", "$", "provider", "->", "id", ")", ",", "$", "reason", ",", "$", "reasonData", ")", ";", "}" ]
Creates a rule for two conflicting packages The rule for conflicting packages A and B is (-A|-B). A is called the issuer and B the provider. @param PackageInterface $issuer The package declaring the conflict @param PackageInterface $provider The package causing the conflict @param int $reason A RULE_* constant describing the reason for generating this rule @param mixed $reasonData Any data, e.g. the package name, that goes with the reason @return Rule The generated rule
[ "Creates", "a", "rule", "for", "two", "conflicting", "packages" ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/DependencyResolver/RuleSetGenerator.php#L119-L127
23,485
mothership-ec/composer
src/Composer/DependencyResolver/RuleSetGenerator.php
RuleSetGenerator.addRule
private function addRule($type, Rule $newRule = null) { if (!$newRule || $this->rules->containsEqual($newRule)) { return; } $this->rules->add($newRule, $type); }
php
private function addRule($type, Rule $newRule = null) { if (!$newRule || $this->rules->containsEqual($newRule)) { return; } $this->rules->add($newRule, $type); }
[ "private", "function", "addRule", "(", "$", "type", ",", "Rule", "$", "newRule", "=", "null", ")", "{", "if", "(", "!", "$", "newRule", "||", "$", "this", "->", "rules", "->", "containsEqual", "(", "$", "newRule", ")", ")", "{", "return", ";", "}", "$", "this", "->", "rules", "->", "add", "(", "$", "newRule", ",", "$", "type", ")", ";", "}" ]
Adds a rule unless it duplicates an existing one of any type To be able to directly pass in the result of one of the rule creation methods null is allowed which will not insert a rule. @param int $type A TYPE_* constant defining the rule type @param Rule $newRule The rule about to be added
[ "Adds", "a", "rule", "unless", "it", "duplicates", "an", "existing", "one", "of", "any", "type" ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/DependencyResolver/RuleSetGenerator.php#L138-L145
23,486
eXistenZNL/PermCheck
src/Config/Loader/Xml.php
Xml.parse
public function parse() { if (!is_string($this->data)) { throw new \RuntimeException('The given data is no valid string'); } libxml_use_internal_errors(true); $xml = simplexml_load_string($this->data); if ($xml === false) { throw new \RuntimeException('Error during the loading of the XML file'); } if (!isset($xml->executables, $xml->excludes)) { throw new \RuntimeException('Missing configuration elements'); } foreach ($xml->excludes->children()->file as $file) { $this->config->addExcludedFile((string) $file); } foreach ($xml->excludes->children()->dir as $dir) { $this->config->addExcludedDir((string) $dir); } foreach ($xml->executables->children() as $file) { $this->config->addExecutableFile((string) $file); } return $this->config; }
php
public function parse() { if (!is_string($this->data)) { throw new \RuntimeException('The given data is no valid string'); } libxml_use_internal_errors(true); $xml = simplexml_load_string($this->data); if ($xml === false) { throw new \RuntimeException('Error during the loading of the XML file'); } if (!isset($xml->executables, $xml->excludes)) { throw new \RuntimeException('Missing configuration elements'); } foreach ($xml->excludes->children()->file as $file) { $this->config->addExcludedFile((string) $file); } foreach ($xml->excludes->children()->dir as $dir) { $this->config->addExcludedDir((string) $dir); } foreach ($xml->executables->children() as $file) { $this->config->addExecutableFile((string) $file); } return $this->config; }
[ "public", "function", "parse", "(", ")", "{", "if", "(", "!", "is_string", "(", "$", "this", "->", "data", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'The given data is no valid string'", ")", ";", "}", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "xml", "=", "simplexml_load_string", "(", "$", "this", "->", "data", ")", ";", "if", "(", "$", "xml", "===", "false", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Error during the loading of the XML file'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "xml", "->", "executables", ",", "$", "xml", "->", "excludes", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Missing configuration elements'", ")", ";", "}", "foreach", "(", "$", "xml", "->", "excludes", "->", "children", "(", ")", "->", "file", "as", "$", "file", ")", "{", "$", "this", "->", "config", "->", "addExcludedFile", "(", "(", "string", ")", "$", "file", ")", ";", "}", "foreach", "(", "$", "xml", "->", "excludes", "->", "children", "(", ")", "->", "dir", "as", "$", "dir", ")", "{", "$", "this", "->", "config", "->", "addExcludedDir", "(", "(", "string", ")", "$", "dir", ")", ";", "}", "foreach", "(", "$", "xml", "->", "executables", "->", "children", "(", ")", "as", "$", "file", ")", "{", "$", "this", "->", "config", "->", "addExecutableFile", "(", "(", "string", ")", "$", "file", ")", ";", "}", "return", "$", "this", "->", "config", ";", "}" ]
Load the configuration and return it in an easy to use config bag. @throws \RuntimeException When an error occurs. @return ConfigInterface
[ "Load", "the", "configuration", "and", "return", "it", "in", "an", "easy", "to", "use", "config", "bag", "." ]
f22f2936350f6b440222fb6ea37dfc382fc4550e
https://github.com/eXistenZNL/PermCheck/blob/f22f2936350f6b440222fb6ea37dfc382fc4550e/src/Config/Loader/Xml.php#L20-L47
23,487
hametuha/wpametu
src/WPametu/UI/Field/Multiple.php
Multiple.build_input
protected function build_input($data, array $fields = []){ $input = $this->get_open_tag($data, $fields); $counter = 1; foreach( $this->get_options() as $key => $label ){ $input .= $this->get_option($key, $label, $counter, $data, $fields); $counter++; } $input .= $this->close_tag; return $input; }
php
protected function build_input($data, array $fields = []){ $input = $this->get_open_tag($data, $fields); $counter = 1; foreach( $this->get_options() as $key => $label ){ $input .= $this->get_option($key, $label, $counter, $data, $fields); $counter++; } $input .= $this->close_tag; return $input; }
[ "protected", "function", "build_input", "(", "$", "data", ",", "array", "$", "fields", "=", "[", "]", ")", "{", "$", "input", "=", "$", "this", "->", "get_open_tag", "(", "$", "data", ",", "$", "fields", ")", ";", "$", "counter", "=", "1", ";", "foreach", "(", "$", "this", "->", "get_options", "(", ")", "as", "$", "key", "=>", "$", "label", ")", "{", "$", "input", ".=", "$", "this", "->", "get_option", "(", "$", "key", ",", "$", "label", ",", "$", "counter", ",", "$", "data", ",", "$", "fields", ")", ";", "$", "counter", "++", ";", "}", "$", "input", ".=", "$", "this", "->", "close_tag", ";", "return", "$", "input", ";", "}" ]
Show input labels @param mixed $data @param array $fields @return string
[ "Show", "input", "labels" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/Multiple.php#L61-L70
23,488
dcsg/EventbriteApiConnector
lib/EventbriteApiConnector/Eventbrite.php
Eventbrite.get
public function get($method, array $params, array $options = array()) { $this->parseOptions($options); $params = array_merge($params, $this->apiKeys); $response = $this->httpAdapter->getContent( sprintf(self::API_ENDPOINT, $this->scheme, $this->outputFormat, $method .'?'. http_build_query($params)), $this->headers ); return $this->responseHandler($response); }
php
public function get($method, array $params, array $options = array()) { $this->parseOptions($options); $params = array_merge($params, $this->apiKeys); $response = $this->httpAdapter->getContent( sprintf(self::API_ENDPOINT, $this->scheme, $this->outputFormat, $method .'?'. http_build_query($params)), $this->headers ); return $this->responseHandler($response); }
[ "public", "function", "get", "(", "$", "method", ",", "array", "$", "params", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "this", "->", "parseOptions", "(", "$", "options", ")", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "this", "->", "apiKeys", ")", ";", "$", "response", "=", "$", "this", "->", "httpAdapter", "->", "getContent", "(", "sprintf", "(", "self", "::", "API_ENDPOINT", ",", "$", "this", "->", "scheme", ",", "$", "this", "->", "outputFormat", ",", "$", "method", ".", "'?'", ".", "http_build_query", "(", "$", "params", ")", ")", ",", "$", "this", "->", "headers", ")", ";", "return", "$", "this", "->", "responseHandler", "(", "$", "response", ")", ";", "}" ]
Calls the Eventbrite API via GET @param string $method Eventbrite API method @param array $params API method params @param array $options Options for calling the API like scheme, headers and output format @return string The content
[ "Calls", "the", "Eventbrite", "API", "via", "GET" ]
3926f6dee8d824601cad7155bc2b5f9748218236
https://github.com/dcsg/EventbriteApiConnector/blob/3926f6dee8d824601cad7155bc2b5f9748218236/lib/EventbriteApiConnector/Eventbrite.php#L79-L91
23,489
dcsg/EventbriteApiConnector
lib/EventbriteApiConnector/Eventbrite.php
Eventbrite.parseOptions
private function parseOptions(array $options) { if (isset($options['headers']) && is_array($options['headers'])) { $this->headers = $options['headers']; } if (isset($options['scheme']) && strtolower($options['scheme']) === 'http') { $this->scheme = 'http'; } if (isset($options['output_format']) && strtolower($options['output_format']) === 'xml') { $this->outputFormat = 'xml'; } }
php
private function parseOptions(array $options) { if (isset($options['headers']) && is_array($options['headers'])) { $this->headers = $options['headers']; } if (isset($options['scheme']) && strtolower($options['scheme']) === 'http') { $this->scheme = 'http'; } if (isset($options['output_format']) && strtolower($options['output_format']) === 'xml') { $this->outputFormat = 'xml'; } }
[ "private", "function", "parseOptions", "(", "array", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'headers'", "]", ")", "&&", "is_array", "(", "$", "options", "[", "'headers'", "]", ")", ")", "{", "$", "this", "->", "headers", "=", "$", "options", "[", "'headers'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'scheme'", "]", ")", "&&", "strtolower", "(", "$", "options", "[", "'scheme'", "]", ")", "===", "'http'", ")", "{", "$", "this", "->", "scheme", "=", "'http'", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'output_format'", "]", ")", "&&", "strtolower", "(", "$", "options", "[", "'output_format'", "]", ")", "===", "'xml'", ")", "{", "$", "this", "->", "outputFormat", "=", "'xml'", ";", "}", "}" ]
Parser for options like scheme, headers and output format. @param array $options @return null
[ "Parser", "for", "options", "like", "scheme", "headers", "and", "output", "format", "." ]
3926f6dee8d824601cad7155bc2b5f9748218236
https://github.com/dcsg/EventbriteApiConnector/blob/3926f6dee8d824601cad7155bc2b5f9748218236/lib/EventbriteApiConnector/Eventbrite.php#L126-L139
23,490
dcsg/EventbriteApiConnector
lib/EventbriteApiConnector/Eventbrite.php
Eventbrite.responseHandler
private function responseHandler($responseBody) { if ('json' === $this->outputFormat) { return $this->validateJsonResponse($responseBody); } return $this->validateXmlResponse($responseBody); }
php
private function responseHandler($responseBody) { if ('json' === $this->outputFormat) { return $this->validateJsonResponse($responseBody); } return $this->validateXmlResponse($responseBody); }
[ "private", "function", "responseHandler", "(", "$", "responseBody", ")", "{", "if", "(", "'json'", "===", "$", "this", "->", "outputFormat", ")", "{", "return", "$", "this", "->", "validateJsonResponse", "(", "$", "responseBody", ")", ";", "}", "return", "$", "this", "->", "validateXmlResponse", "(", "$", "responseBody", ")", ";", "}" ]
Handler for validate the response body. @param string $responseBody Content body of the response @return string
[ "Handler", "for", "validate", "the", "response", "body", "." ]
3926f6dee8d824601cad7155bc2b5f9748218236
https://github.com/dcsg/EventbriteApiConnector/blob/3926f6dee8d824601cad7155bc2b5f9748218236/lib/EventbriteApiConnector/Eventbrite.php#L148-L155
23,491
dcsg/EventbriteApiConnector
lib/EventbriteApiConnector/Eventbrite.php
Eventbrite.validateJsonResponse
private function validateJsonResponse($responseBody) { $data = json_decode($responseBody); if (json_last_error() !== JSON_ERROR_NONE) { throw new \Exception('Error decoding JSON.'); } if (isset($data->error)) { throw new \Exception($data->error->error_message); } if (empty($data)) { throw new \Exception('No results found.'); } return $responseBody; }
php
private function validateJsonResponse($responseBody) { $data = json_decode($responseBody); if (json_last_error() !== JSON_ERROR_NONE) { throw new \Exception('Error decoding JSON.'); } if (isset($data->error)) { throw new \Exception($data->error->error_message); } if (empty($data)) { throw new \Exception('No results found.'); } return $responseBody; }
[ "private", "function", "validateJsonResponse", "(", "$", "responseBody", ")", "{", "$", "data", "=", "json_decode", "(", "$", "responseBody", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "throw", "new", "\\", "Exception", "(", "'Error decoding JSON.'", ")", ";", "}", "if", "(", "isset", "(", "$", "data", "->", "error", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "data", "->", "error", "->", "error_message", ")", ";", "}", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'No results found.'", ")", ";", "}", "return", "$", "responseBody", ";", "}" ]
Parses the response content for the JSON output format @param string $responseBody @return string @throws \Exception
[ "Parses", "the", "response", "content", "for", "the", "JSON", "output", "format" ]
3926f6dee8d824601cad7155bc2b5f9748218236
https://github.com/dcsg/EventbriteApiConnector/blob/3926f6dee8d824601cad7155bc2b5f9748218236/lib/EventbriteApiConnector/Eventbrite.php#L165-L182
23,492
dcsg/EventbriteApiConnector
lib/EventbriteApiConnector/Eventbrite.php
Eventbrite.validateXmlResponse
private function validateXmlResponse($responseBody) { $data = simplexml_load_string($responseBody); if (isset($data->error_type)) { throw new \Exception($data->error_message); } return $responseBody; }
php
private function validateXmlResponse($responseBody) { $data = simplexml_load_string($responseBody); if (isset($data->error_type)) { throw new \Exception($data->error_message); } return $responseBody; }
[ "private", "function", "validateXmlResponse", "(", "$", "responseBody", ")", "{", "$", "data", "=", "simplexml_load_string", "(", "$", "responseBody", ")", ";", "if", "(", "isset", "(", "$", "data", "->", "error_type", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "data", "->", "error_message", ")", ";", "}", "return", "$", "responseBody", ";", "}" ]
Parses the response content for the XML output format @param string $responseBody @return string @throws \Exception
[ "Parses", "the", "response", "content", "for", "the", "XML", "output", "format" ]
3926f6dee8d824601cad7155bc2b5f9748218236
https://github.com/dcsg/EventbriteApiConnector/blob/3926f6dee8d824601cad7155bc2b5f9748218236/lib/EventbriteApiConnector/Eventbrite.php#L192-L201
23,493
getuisdk/getui-php-sdk
src/PBMessage.php
PBMessage.getTypes
public function getTypes($number) { $binstring = decbin((int) $number); $types = array(); $mlen = strlen($binstring) - 3; $low = substr($binstring, $mlen, strlen($binstring)); $high = substr($binstring, 0, $mlen) . '0000'; $types['wired'] = bindec($low); $types['field'] = bindec($binstring) >> 3; return $types; }
php
public function getTypes($number) { $binstring = decbin((int) $number); $types = array(); $mlen = strlen($binstring) - 3; $low = substr($binstring, $mlen, strlen($binstring)); $high = substr($binstring, 0, $mlen) . '0000'; $types['wired'] = bindec($low); $types['field'] = bindec($binstring) >> 3; return $types; }
[ "public", "function", "getTypes", "(", "$", "number", ")", "{", "$", "binstring", "=", "decbin", "(", "(", "int", ")", "$", "number", ")", ";", "$", "types", "=", "array", "(", ")", ";", "$", "mlen", "=", "strlen", "(", "$", "binstring", ")", "-", "3", ";", "$", "low", "=", "substr", "(", "$", "binstring", ",", "$", "mlen", ",", "strlen", "(", "$", "binstring", ")", ")", ";", "$", "high", "=", "substr", "(", "$", "binstring", ",", "0", ",", "$", "mlen", ")", ".", "'0000'", ";", "$", "types", "[", "'wired'", "]", "=", "bindec", "(", "$", "low", ")", ";", "$", "types", "[", "'field'", "]", "=", "bindec", "(", "$", "binstring", ")", ">>", "3", ";", "return", "$", "types", ";", "}" ]
Get the wired_type and field_type @param $number @return array wired_type, field_type
[ "Get", "the", "wired_type", "and", "field_type" ]
e91773b099bcbfd7492a44086b373d1c9fee37e2
https://github.com/getuisdk/getui-php-sdk/blob/e91773b099bcbfd7492a44086b373d1c9fee37e2/src/PBMessage.php#L77-L87
23,494
getuisdk/getui-php-sdk
src/PBMessage.php
PBMessage.serializeToString
public function serializeToString($rec = -1) { $string = ''; // wired and type if ($rec > -1) { $string .= $this->base128->setValue($rec << 3 | $this->wired_type); } $stringinner = ''; foreach ($this->fields as $index => $field) { if (is_array($this->values[$index]) && count($this->values[$index]) > 0) { // make serialization for every array foreach ($this->values[$index] as $array) { $newstring = ''; if (method_exists($array, 'serializeToString')) { $newstring .= $array->serializeToString($index); } $stringinner .= $newstring; } } elseif ($this->values[$index] !== null) { // wired and type $newstring = ''; if (method_exists($this->values[$index], 'serializeToString')) { $newstring .= $this->values[$index]->serializeToString($index); } $stringinner .= $newstring; } } $this->serializeChunk($stringinner); if ($this->wired_type === PBMessage::WIRED_LENGTH_DELIMITED && $rec > -1) { $stringinner = $this->base128->setValue(strlen($stringinner) / PBMessage::MODUS) . $stringinner; } return $string . $stringinner; }
php
public function serializeToString($rec = -1) { $string = ''; // wired and type if ($rec > -1) { $string .= $this->base128->setValue($rec << 3 | $this->wired_type); } $stringinner = ''; foreach ($this->fields as $index => $field) { if (is_array($this->values[$index]) && count($this->values[$index]) > 0) { // make serialization for every array foreach ($this->values[$index] as $array) { $newstring = ''; if (method_exists($array, 'serializeToString')) { $newstring .= $array->serializeToString($index); } $stringinner .= $newstring; } } elseif ($this->values[$index] !== null) { // wired and type $newstring = ''; if (method_exists($this->values[$index], 'serializeToString')) { $newstring .= $this->values[$index]->serializeToString($index); } $stringinner .= $newstring; } } $this->serializeChunk($stringinner); if ($this->wired_type === PBMessage::WIRED_LENGTH_DELIMITED && $rec > -1) { $stringinner = $this->base128->setValue(strlen($stringinner) / PBMessage::MODUS) . $stringinner; } return $string . $stringinner; }
[ "public", "function", "serializeToString", "(", "$", "rec", "=", "-", "1", ")", "{", "$", "string", "=", "''", ";", "// wired and type\r", "if", "(", "$", "rec", ">", "-", "1", ")", "{", "$", "string", ".=", "$", "this", "->", "base128", "->", "setValue", "(", "$", "rec", "<<", "3", "|", "$", "this", "->", "wired_type", ")", ";", "}", "$", "stringinner", "=", "''", ";", "foreach", "(", "$", "this", "->", "fields", "as", "$", "index", "=>", "$", "field", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "values", "[", "$", "index", "]", ")", "&&", "count", "(", "$", "this", "->", "values", "[", "$", "index", "]", ")", ">", "0", ")", "{", "// make serialization for every array\r", "foreach", "(", "$", "this", "->", "values", "[", "$", "index", "]", "as", "$", "array", ")", "{", "$", "newstring", "=", "''", ";", "if", "(", "method_exists", "(", "$", "array", ",", "'serializeToString'", ")", ")", "{", "$", "newstring", ".=", "$", "array", "->", "serializeToString", "(", "$", "index", ")", ";", "}", "$", "stringinner", ".=", "$", "newstring", ";", "}", "}", "elseif", "(", "$", "this", "->", "values", "[", "$", "index", "]", "!==", "null", ")", "{", "// wired and type\r", "$", "newstring", "=", "''", ";", "if", "(", "method_exists", "(", "$", "this", "->", "values", "[", "$", "index", "]", ",", "'serializeToString'", ")", ")", "{", "$", "newstring", ".=", "$", "this", "->", "values", "[", "$", "index", "]", "->", "serializeToString", "(", "$", "index", ")", ";", "}", "$", "stringinner", ".=", "$", "newstring", ";", "}", "}", "$", "this", "->", "serializeChunk", "(", "$", "stringinner", ")", ";", "if", "(", "$", "this", "->", "wired_type", "===", "PBMessage", "::", "WIRED_LENGTH_DELIMITED", "&&", "$", "rec", ">", "-", "1", ")", "{", "$", "stringinner", "=", "$", "this", "->", "base128", "->", "setValue", "(", "strlen", "(", "$", "stringinner", ")", "/", "PBMessage", "::", "MODUS", ")", ".", "$", "stringinner", ";", "}", "return", "$", "string", ".", "$", "stringinner", ";", "}" ]
Encodes a Message @param mixed $rec @return string the encoded message
[ "Encodes", "a", "Message" ]
e91773b099bcbfd7492a44086b373d1c9fee37e2
https://github.com/getuisdk/getui-php-sdk/blob/e91773b099bcbfd7492a44086b373d1c9fee37e2/src/PBMessage.php#L95-L135
23,495
getuisdk/getui-php-sdk
src/PBMessage.php
PBMessage.addArrValue
protected function addArrValue($index) { $class_name = $this->fields[$index]; $real_class_name = __NAMESPACE__ . "\\" . $class_name; return $this->values[$index][] = new $real_class_name(); }
php
protected function addArrValue($index) { $class_name = $this->fields[$index]; $real_class_name = __NAMESPACE__ . "\\" . $class_name; return $this->values[$index][] = new $real_class_name(); }
[ "protected", "function", "addArrValue", "(", "$", "index", ")", "{", "$", "class_name", "=", "$", "this", "->", "fields", "[", "$", "index", "]", ";", "$", "real_class_name", "=", "__NAMESPACE__", ".", "\"\\\\\"", ".", "$", "class_name", ";", "return", "$", "this", "->", "values", "[", "$", "index", "]", "[", "]", "=", "new", "$", "real_class_name", "(", ")", ";", "}" ]
Add an array value @param int - index of the field
[ "Add", "an", "array", "value" ]
e91773b099bcbfd7492a44086b373d1c9fee37e2
https://github.com/getuisdk/getui-php-sdk/blob/e91773b099bcbfd7492a44086b373d1c9fee37e2/src/PBMessage.php#L236-L241
23,496
getuisdk/getui-php-sdk
src/PBMessage.php
PBMessage.setValue
protected function setValue($index, $value) { if (gettype($value) === 'object') { $this->values[$index] = $value; } else { $class_name = $this->fields[$index]; $real_class_name = __NAMESPACE__ . "\\" . $class_name; $this->values[$index] = new $real_class_name(); $this->values[$index]->value = $value; } return $this; }
php
protected function setValue($index, $value) { if (gettype($value) === 'object') { $this->values[$index] = $value; } else { $class_name = $this->fields[$index]; $real_class_name = __NAMESPACE__ . "\\" . $class_name; $this->values[$index] = new $real_class_name(); $this->values[$index]->value = $value; } return $this; }
[ "protected", "function", "setValue", "(", "$", "index", ",", "$", "value", ")", "{", "if", "(", "gettype", "(", "$", "value", ")", "===", "'object'", ")", "{", "$", "this", "->", "values", "[", "$", "index", "]", "=", "$", "value", ";", "}", "else", "{", "$", "class_name", "=", "$", "this", "->", "fields", "[", "$", "index", "]", ";", "$", "real_class_name", "=", "__NAMESPACE__", ".", "\"\\\\\"", ".", "$", "class_name", ";", "$", "this", "->", "values", "[", "$", "index", "]", "=", "new", "$", "real_class_name", "(", ")", ";", "$", "this", "->", "values", "[", "$", "index", "]", "->", "value", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Set an value @param int - index of the field @param Mixed $value @return mixed
[ "Set", "an", "value" ]
e91773b099bcbfd7492a44086b373d1c9fee37e2
https://github.com/getuisdk/getui-php-sdk/blob/e91773b099bcbfd7492a44086b373d1c9fee37e2/src/PBMessage.php#L269-L280
23,497
getuisdk/getui-php-sdk
src/PBMessage.php
PBMessage.saveString
protected function saveString($ch, $string) { $this->dString .= $string; $content_length = strlen($this->dString); return strlen($string); }
php
protected function saveString($ch, $string) { $this->dString .= $string; $content_length = strlen($this->dString); return strlen($string); }
[ "protected", "function", "saveString", "(", "$", "ch", ",", "$", "string", ")", "{", "$", "this", "->", "dString", ".=", "$", "string", ";", "$", "content_length", "=", "strlen", "(", "$", "this", "->", "dString", ")", ";", "return", "strlen", "(", "$", "string", ")", ";", "}" ]
Helper method for send string
[ "Helper", "method", "for", "send", "string" ]
e91773b099bcbfd7492a44086b373d1c9fee37e2
https://github.com/getuisdk/getui-php-sdk/blob/e91773b099bcbfd7492a44086b373d1c9fee37e2/src/PBMessage.php#L319-L324
23,498
pinepain/amqpy
src/AMQPy/AbstractConsumer.php
AbstractConsumer.failure
public function failure(Exception $e, Delivery $delivery, AbstractListener $listener) { $listener->resend($delivery); }
php
public function failure(Exception $e, Delivery $delivery, AbstractListener $listener) { $listener->resend($delivery); }
[ "public", "function", "failure", "(", "Exception", "$", "e", ",", "Delivery", "$", "delivery", ",", "AbstractListener", "$", "listener", ")", "{", "$", "listener", "->", "resend", "(", "$", "delivery", ")", ";", "}" ]
Handle any exception during queued message data processing.
[ "Handle", "any", "exception", "during", "queued", "message", "data", "processing", "." ]
fc61dacc37a97a100caf67232a72be32dd7cc896
https://github.com/pinepain/amqpy/blob/fc61dacc37a97a100caf67232a72be32dd7cc896/src/AMQPy/AbstractConsumer.php#L37-L40
23,499
SporkCode/Spork
src/View/Helper/HeadScript.php
HeadScript.toString
public function toString($indent = null) { $helperManager = $this->getView()->getHelperPluginManager(); if ($helperManager->has('dojo')) { $dojo = $helperManager->get('dojo'); $dojo->initialize(); } return parent::toString($indent); }
php
public function toString($indent = null) { $helperManager = $this->getView()->getHelperPluginManager(); if ($helperManager->has('dojo')) { $dojo = $helperManager->get('dojo'); $dojo->initialize(); } return parent::toString($indent); }
[ "public", "function", "toString", "(", "$", "indent", "=", "null", ")", "{", "$", "helperManager", "=", "$", "this", "->", "getView", "(", ")", "->", "getHelperPluginManager", "(", ")", ";", "if", "(", "$", "helperManager", "->", "has", "(", "'dojo'", ")", ")", "{", "$", "dojo", "=", "$", "helperManager", "->", "get", "(", "'dojo'", ")", ";", "$", "dojo", "->", "initialize", "(", ")", ";", "}", "return", "parent", "::", "toString", "(", "$", "indent", ")", ";", "}" ]
Find an initialize Dojo helper before rendering head scripts @see \Zend\View\Helper\HeadScript::toString() @param string $indent @return string
[ "Find", "an", "initialize", "Dojo", "helper", "before", "rendering", "head", "scripts" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/HeadScript.php#L22-L30