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
228,600
gurukami/php-array
src/Arrays.php
Arrays.delete
public static function delete($key, &$array) { if (!is_array($array)) { return false; } if ($key == '') { unset($array[$key]); return true; } if ($key === '[]') { return false; } return self::parseAndValidateKeys($key, $array, 'delete')['completed']; }
php
public static function delete($key, &$array) { if (!is_array($array)) { return false; } if ($key == '') { unset($array[$key]); return true; } if ($key === '[]') { return false; } return self::parseAndValidateKeys($key, $array, 'delete')['completed']; }
[ "public", "static", "function", "delete", "(", "$", "key", ",", "&", "$", "array", ")", "{", "if", "(", "!", "is_array", "(", "$", "array", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "key", "==", "''", ")", "{", "unset", "(", "$", "array", "[", "$", "key", "]", ")", ";", "return", "true", ";", "}", "if", "(", "$", "key", "===", "'[]'", ")", "{", "return", "false", ";", "}", "return", "self", "::", "parseAndValidateKeys", "(", "$", "key", ",", "$", "array", ",", "'delete'", ")", "[", "'completed'", "]", ";", "}" ]
Delete element from the array by a string representation @param string $key <p>Name key in the array. Example: key[sub_key][sub_sub_key]</p> @param array $array <p>The array. This array is passed by reference</p> @return bool returns true if success, false otherwise
[ "Delete", "element", "from", "the", "array", "by", "a", "string", "representation" ]
634715e70efd67edfb99d2a74e09cec809280abd
https://github.com/gurukami/php-array/blob/634715e70efd67edfb99d2a74e09cec809280abd/src/Arrays.php#L93-L106
228,601
antaresproject/core
src/components/view/src/Notification/AbstractNotificationTemplate.php
AbstractNotificationTemplate.getRecipients
public function getRecipients() { if (empty($this->recipients)) { return []; } $recipients = ($this->recipients instanceof Collection) ? $this->recipients->toArray() : $this->recipients; if (!is_array($recipients)) { return $recipients; } $return = []; foreach ($recipients as $recipient) { if ($recipient instanceof \Illuminate\Database\Eloquent\Model) { if ($this->type == 'email' and ! isset($recipient->email)) { continue; } if ($this->type == 'email') { array_push($return, $recipient->email); } if ($this->type == 'sms' and ! isset($recipient->phone)) { continue; } if ($this->type == 'sms') { array_push($return, $recipient->phone); } } } return array_filter(array_unique($return)); }
php
public function getRecipients() { if (empty($this->recipients)) { return []; } $recipients = ($this->recipients instanceof Collection) ? $this->recipients->toArray() : $this->recipients; if (!is_array($recipients)) { return $recipients; } $return = []; foreach ($recipients as $recipient) { if ($recipient instanceof \Illuminate\Database\Eloquent\Model) { if ($this->type == 'email' and ! isset($recipient->email)) { continue; } if ($this->type == 'email') { array_push($return, $recipient->email); } if ($this->type == 'sms' and ! isset($recipient->phone)) { continue; } if ($this->type == 'sms') { array_push($return, $recipient->phone); } } } return array_filter(array_unique($return)); }
[ "public", "function", "getRecipients", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "recipients", ")", ")", "{", "return", "[", "]", ";", "}", "$", "recipients", "=", "(", "$", "this", "->", "recipients", "instanceof", "Collection", ")", "?", "$", "this", "->", "recipients", "->", "toArray", "(", ")", ":", "$", "this", "->", "recipients", ";", "if", "(", "!", "is_array", "(", "$", "recipients", ")", ")", "{", "return", "$", "recipients", ";", "}", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "recipients", "as", "$", "recipient", ")", "{", "if", "(", "$", "recipient", "instanceof", "\\", "Illuminate", "\\", "Database", "\\", "Eloquent", "\\", "Model", ")", "{", "if", "(", "$", "this", "->", "type", "==", "'email'", "and", "!", "isset", "(", "$", "recipient", "->", "email", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "this", "->", "type", "==", "'email'", ")", "{", "array_push", "(", "$", "return", ",", "$", "recipient", "->", "email", ")", ";", "}", "if", "(", "$", "this", "->", "type", "==", "'sms'", "and", "!", "isset", "(", "$", "recipient", "->", "phone", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "this", "->", "type", "==", "'sms'", ")", "{", "array_push", "(", "$", "return", ",", "$", "recipient", "->", "phone", ")", ";", "}", "}", "}", "return", "array_filter", "(", "array_unique", "(", "$", "return", ")", ")", ";", "}" ]
notification recipients values getter @return mixed
[ "notification", "recipients", "values", "getter" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Notification/AbstractNotificationTemplate.php#L203-L234
228,602
antaresproject/core
src/components/view/src/Notification/AbstractNotificationTemplate.php
AbstractNotificationTemplate.getVariables
public function getVariables() { $variables = app()->make('antares.notifications')->all(); $extensions = app()->make('antares.memory')->make('component')->get('extensions.active'); if (empty($variables)) { return []; } $return = []; foreach ($variables as $extension => $config) { $name = ucfirst($extension == 'foundation' ? $extension : array_get($extensions, $extension . '.name')); $vars = $config['variables']; if (empty($vars)) { continue; } foreach ($vars as $key => $variable) { $return[$name][] = ['name' => $key, 'description' => isset($variable['description']) ? $variable['description'] : '']; } } Event::fire('notifications:' . snake_case(class_basename($this)) . '.variables', [&$return]); return $return; }
php
public function getVariables() { $variables = app()->make('antares.notifications')->all(); $extensions = app()->make('antares.memory')->make('component')->get('extensions.active'); if (empty($variables)) { return []; } $return = []; foreach ($variables as $extension => $config) { $name = ucfirst($extension == 'foundation' ? $extension : array_get($extensions, $extension . '.name')); $vars = $config['variables']; if (empty($vars)) { continue; } foreach ($vars as $key => $variable) { $return[$name][] = ['name' => $key, 'description' => isset($variable['description']) ? $variable['description'] : '']; } } Event::fire('notifications:' . snake_case(class_basename($this)) . '.variables', [&$return]); return $return; }
[ "public", "function", "getVariables", "(", ")", "{", "$", "variables", "=", "app", "(", ")", "->", "make", "(", "'antares.notifications'", ")", "->", "all", "(", ")", ";", "$", "extensions", "=", "app", "(", ")", "->", "make", "(", "'antares.memory'", ")", "->", "make", "(", "'component'", ")", "->", "get", "(", "'extensions.active'", ")", ";", "if", "(", "empty", "(", "$", "variables", ")", ")", "{", "return", "[", "]", ";", "}", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "variables", "as", "$", "extension", "=>", "$", "config", ")", "{", "$", "name", "=", "ucfirst", "(", "$", "extension", "==", "'foundation'", "?", "$", "extension", ":", "array_get", "(", "$", "extensions", ",", "$", "extension", ".", "'.name'", ")", ")", ";", "$", "vars", "=", "$", "config", "[", "'variables'", "]", ";", "if", "(", "empty", "(", "$", "vars", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "vars", "as", "$", "key", "=>", "$", "variable", ")", "{", "$", "return", "[", "$", "name", "]", "[", "]", "=", "[", "'name'", "=>", "$", "key", ",", "'description'", "=>", "isset", "(", "$", "variable", "[", "'description'", "]", ")", "?", "$", "variable", "[", "'description'", "]", ":", "''", "]", ";", "}", "}", "Event", "::", "fire", "(", "'notifications:'", ".", "snake_case", "(", "class_basename", "(", "$", "this", ")", ")", ".", "'.variables'", ",", "[", "&", "$", "return", "]", ")", ";", "return", "$", "return", ";", "}" ]
get available variables @return array
[ "get", "available", "variables" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Notification/AbstractNotificationTemplate.php#L319-L341
228,603
minmb/phpmailer
class.phpmailer.php
PHPMailer.PreSend
public function PreSend() { try { $this->mailHeader = ""; if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL); } // Set whether the message is multipart/alternative if(!empty($this->AltBody)) { $this->ContentType = 'multipart/alternative'; } $this->error_count = 0; // reset errors $this->SetMessageType(); //Refuse to send an empty message if (empty($this->Body)) { throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL); } $this->MIMEHeader = $this->CreateHeader(); $this->MIMEBody = $this->CreateBody(); // To capture the complete message when using mail(), create // an extra header list which CreateHeader() doesn't fold in if ($this->Mailer == 'mail') { if (count($this->to) > 0) { $this->mailHeader .= $this->AddrAppend("To", $this->to); } else { $this->mailHeader .= $this->HeaderLine("To", "undisclosed-recipients:;"); } $this->mailHeader .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader(trim($this->Subject)))); // if(count($this->cc) > 0) { // $this->mailHeader .= $this->AddrAppend("Cc", $this->cc); // } } // digitally sign with DKIM if enabled if (!empty($this->DKIM_domain) && !empty($this->DKIM_private) && !empty($this->DKIM_selector) && !empty($this->DKIM_domain) && file_exists($this->DKIM_private)) { $header_dkim = $this->DKIM_Add($this->MIMEHeader, $this->EncodeHeader($this->SecureHeader($this->Subject)), $this->MIMEBody); $this->MIMEHeader = str_replace("\r\n", "\n", $header_dkim) . $this->MIMEHeader; } return true; } catch (phpmailerException $e) { $this->SetError($e->getMessage()); if ($this->exceptions) { throw $e; } return false; } }
php
public function PreSend() { try { $this->mailHeader = ""; if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL); } // Set whether the message is multipart/alternative if(!empty($this->AltBody)) { $this->ContentType = 'multipart/alternative'; } $this->error_count = 0; // reset errors $this->SetMessageType(); //Refuse to send an empty message if (empty($this->Body)) { throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL); } $this->MIMEHeader = $this->CreateHeader(); $this->MIMEBody = $this->CreateBody(); // To capture the complete message when using mail(), create // an extra header list which CreateHeader() doesn't fold in if ($this->Mailer == 'mail') { if (count($this->to) > 0) { $this->mailHeader .= $this->AddrAppend("To", $this->to); } else { $this->mailHeader .= $this->HeaderLine("To", "undisclosed-recipients:;"); } $this->mailHeader .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader(trim($this->Subject)))); // if(count($this->cc) > 0) { // $this->mailHeader .= $this->AddrAppend("Cc", $this->cc); // } } // digitally sign with DKIM if enabled if (!empty($this->DKIM_domain) && !empty($this->DKIM_private) && !empty($this->DKIM_selector) && !empty($this->DKIM_domain) && file_exists($this->DKIM_private)) { $header_dkim = $this->DKIM_Add($this->MIMEHeader, $this->EncodeHeader($this->SecureHeader($this->Subject)), $this->MIMEBody); $this->MIMEHeader = str_replace("\r\n", "\n", $header_dkim) . $this->MIMEHeader; } return true; } catch (phpmailerException $e) { $this->SetError($e->getMessage()); if ($this->exceptions) { throw $e; } return false; } }
[ "public", "function", "PreSend", "(", ")", "{", "try", "{", "$", "this", "->", "mailHeader", "=", "\"\"", ";", "if", "(", "(", "count", "(", "$", "this", "->", "to", ")", "+", "count", "(", "$", "this", "->", "cc", ")", "+", "count", "(", "$", "this", "->", "bcc", ")", ")", "<", "1", ")", "{", "throw", "new", "phpmailerException", "(", "$", "this", "->", "Lang", "(", "'provide_address'", ")", ",", "self", "::", "STOP_CRITICAL", ")", ";", "}", "// Set whether the message is multipart/alternative", "if", "(", "!", "empty", "(", "$", "this", "->", "AltBody", ")", ")", "{", "$", "this", "->", "ContentType", "=", "'multipart/alternative'", ";", "}", "$", "this", "->", "error_count", "=", "0", ";", "// reset errors", "$", "this", "->", "SetMessageType", "(", ")", ";", "//Refuse to send an empty message", "if", "(", "empty", "(", "$", "this", "->", "Body", ")", ")", "{", "throw", "new", "phpmailerException", "(", "$", "this", "->", "Lang", "(", "'empty_message'", ")", ",", "self", "::", "STOP_CRITICAL", ")", ";", "}", "$", "this", "->", "MIMEHeader", "=", "$", "this", "->", "CreateHeader", "(", ")", ";", "$", "this", "->", "MIMEBody", "=", "$", "this", "->", "CreateBody", "(", ")", ";", "// To capture the complete message when using mail(), create", "// an extra header list which CreateHeader() doesn't fold in", "if", "(", "$", "this", "->", "Mailer", "==", "'mail'", ")", "{", "if", "(", "count", "(", "$", "this", "->", "to", ")", ">", "0", ")", "{", "$", "this", "->", "mailHeader", ".=", "$", "this", "->", "AddrAppend", "(", "\"To\"", ",", "$", "this", "->", "to", ")", ";", "}", "else", "{", "$", "this", "->", "mailHeader", ".=", "$", "this", "->", "HeaderLine", "(", "\"To\"", ",", "\"undisclosed-recipients:;\"", ")", ";", "}", "$", "this", "->", "mailHeader", ".=", "$", "this", "->", "HeaderLine", "(", "'Subject'", ",", "$", "this", "->", "EncodeHeader", "(", "$", "this", "->", "SecureHeader", "(", "trim", "(", "$", "this", "->", "Subject", ")", ")", ")", ")", ";", "// if(count($this->cc) > 0) {", "// $this->mailHeader .= $this->AddrAppend(\"Cc\", $this->cc);", "// }", "}", "// digitally sign with DKIM if enabled", "if", "(", "!", "empty", "(", "$", "this", "->", "DKIM_domain", ")", "&&", "!", "empty", "(", "$", "this", "->", "DKIM_private", ")", "&&", "!", "empty", "(", "$", "this", "->", "DKIM_selector", ")", "&&", "!", "empty", "(", "$", "this", "->", "DKIM_domain", ")", "&&", "file_exists", "(", "$", "this", "->", "DKIM_private", ")", ")", "{", "$", "header_dkim", "=", "$", "this", "->", "DKIM_Add", "(", "$", "this", "->", "MIMEHeader", ",", "$", "this", "->", "EncodeHeader", "(", "$", "this", "->", "SecureHeader", "(", "$", "this", "->", "Subject", ")", ")", ",", "$", "this", "->", "MIMEBody", ")", ";", "$", "this", "->", "MIMEHeader", "=", "str_replace", "(", "\"\\r\\n\"", ",", "\"\\n\"", ",", "$", "header_dkim", ")", ".", "$", "this", "->", "MIMEHeader", ";", "}", "return", "true", ";", "}", "catch", "(", "phpmailerException", "$", "e", ")", "{", "$", "this", "->", "SetError", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "if", "(", "$", "this", "->", "exceptions", ")", "{", "throw", "$", "e", ";", "}", "return", "false", ";", "}", "}" ]
Prep mail by constructing all message entities @return bool
[ "Prep", "mail", "by", "constructing", "all", "message", "entities" ]
df443234ad0ca10cbf91a0c0a728b256afcab1d1
https://github.com/minmb/phpmailer/blob/df443234ad0ca10cbf91a0c0a728b256afcab1d1/class.phpmailer.php#L705-L756
228,604
minmb/phpmailer
class.phpmailer.php
PHPMailer.PostSend
public function PostSend() { $rtn = false; try { // Choose the mailer and send through it switch($this->Mailer) { case 'sendmail': $rtn = $this->SendmailSend($this->MIMEHeader, $this->MIMEBody); break; case 'smtp': $rtn = $this->SmtpSend($this->MIMEHeader, $this->MIMEBody); break; case 'mail': $rtn = $this->MailSend($this->MIMEHeader, $this->MIMEBody); break; default: $rtn = $this->MailSend($this->MIMEHeader, $this->MIMEBody); break; } } catch (phpmailerException $e) { $this->SetError($e->getMessage()); if ($this->exceptions) { throw $e; } if ($this->SMTPDebug) { $this->edebug($e->getMessage()."\n"); } return false; } return $rtn; }
php
public function PostSend() { $rtn = false; try { // Choose the mailer and send through it switch($this->Mailer) { case 'sendmail': $rtn = $this->SendmailSend($this->MIMEHeader, $this->MIMEBody); break; case 'smtp': $rtn = $this->SmtpSend($this->MIMEHeader, $this->MIMEBody); break; case 'mail': $rtn = $this->MailSend($this->MIMEHeader, $this->MIMEBody); break; default: $rtn = $this->MailSend($this->MIMEHeader, $this->MIMEBody); break; } } catch (phpmailerException $e) { $this->SetError($e->getMessage()); if ($this->exceptions) { throw $e; } if ($this->SMTPDebug) { $this->edebug($e->getMessage()."\n"); } return false; } return $rtn; }
[ "public", "function", "PostSend", "(", ")", "{", "$", "rtn", "=", "false", ";", "try", "{", "// Choose the mailer and send through it", "switch", "(", "$", "this", "->", "Mailer", ")", "{", "case", "'sendmail'", ":", "$", "rtn", "=", "$", "this", "->", "SendmailSend", "(", "$", "this", "->", "MIMEHeader", ",", "$", "this", "->", "MIMEBody", ")", ";", "break", ";", "case", "'smtp'", ":", "$", "rtn", "=", "$", "this", "->", "SmtpSend", "(", "$", "this", "->", "MIMEHeader", ",", "$", "this", "->", "MIMEBody", ")", ";", "break", ";", "case", "'mail'", ":", "$", "rtn", "=", "$", "this", "->", "MailSend", "(", "$", "this", "->", "MIMEHeader", ",", "$", "this", "->", "MIMEBody", ")", ";", "break", ";", "default", ":", "$", "rtn", "=", "$", "this", "->", "MailSend", "(", "$", "this", "->", "MIMEHeader", ",", "$", "this", "->", "MIMEBody", ")", ";", "break", ";", "}", "}", "catch", "(", "phpmailerException", "$", "e", ")", "{", "$", "this", "->", "SetError", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "if", "(", "$", "this", "->", "exceptions", ")", "{", "throw", "$", "e", ";", "}", "if", "(", "$", "this", "->", "SMTPDebug", ")", "{", "$", "this", "->", "edebug", "(", "$", "e", "->", "getMessage", "(", ")", ".", "\"\\n\"", ")", ";", "}", "return", "false", ";", "}", "return", "$", "rtn", ";", "}" ]
Actual Email transport function Send the email via the selected mechanism @return bool
[ "Actual", "Email", "transport", "function", "Send", "the", "email", "via", "the", "selected", "mechanism" ]
df443234ad0ca10cbf91a0c0a728b256afcab1d1
https://github.com/minmb/phpmailer/blob/df443234ad0ca10cbf91a0c0a728b256afcab1d1/class.phpmailer.php#L763-L793
228,605
minmb/phpmailer
class.phpmailer.php
PHPMailer.GetMailMIME
public function GetMailMIME() { $result = ''; switch($this->message_type) { case 'inline': $result .= $this->HeaderLine('Content-Type', 'multipart/related;'); $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); break; case 'attach': case 'inline_attach': case 'alt_attach': case 'alt_inline_attach': $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); break; case 'alt': case 'alt_inline': $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); break; default: // Catches case 'plain': and case '': $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); $result .= $this->TextLine('Content-Type: '.$this->ContentType.'; charset='.$this->CharSet); break; } if($this->Mailer != 'mail') { $result .= $this->LE; } return $result; }
php
public function GetMailMIME() { $result = ''; switch($this->message_type) { case 'inline': $result .= $this->HeaderLine('Content-Type', 'multipart/related;'); $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); break; case 'attach': case 'inline_attach': case 'alt_attach': case 'alt_inline_attach': $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); break; case 'alt': case 'alt_inline': $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); break; default: // Catches case 'plain': and case '': $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); $result .= $this->TextLine('Content-Type: '.$this->ContentType.'; charset='.$this->CharSet); break; } if($this->Mailer != 'mail') { $result .= $this->LE; } return $result; }
[ "public", "function", "GetMailMIME", "(", ")", "{", "$", "result", "=", "''", ";", "switch", "(", "$", "this", "->", "message_type", ")", "{", "case", "'inline'", ":", "$", "result", ".=", "$", "this", "->", "HeaderLine", "(", "'Content-Type'", ",", "'multipart/related;'", ")", ";", "$", "result", ".=", "$", "this", "->", "TextLine", "(", "\"\\tboundary=\\\"\"", ".", "$", "this", "->", "boundary", "[", "1", "]", ".", "'\"'", ")", ";", "break", ";", "case", "'attach'", ":", "case", "'inline_attach'", ":", "case", "'alt_attach'", ":", "case", "'alt_inline_attach'", ":", "$", "result", ".=", "$", "this", "->", "HeaderLine", "(", "'Content-Type'", ",", "'multipart/mixed;'", ")", ";", "$", "result", ".=", "$", "this", "->", "TextLine", "(", "\"\\tboundary=\\\"\"", ".", "$", "this", "->", "boundary", "[", "1", "]", ".", "'\"'", ")", ";", "break", ";", "case", "'alt'", ":", "case", "'alt_inline'", ":", "$", "result", ".=", "$", "this", "->", "HeaderLine", "(", "'Content-Type'", ",", "'multipart/alternative;'", ")", ";", "$", "result", ".=", "$", "this", "->", "TextLine", "(", "\"\\tboundary=\\\"\"", ".", "$", "this", "->", "boundary", "[", "1", "]", ".", "'\"'", ")", ";", "break", ";", "default", ":", "// Catches case 'plain': and case '':", "$", "result", ".=", "$", "this", "->", "HeaderLine", "(", "'Content-Transfer-Encoding'", ",", "$", "this", "->", "Encoding", ")", ";", "$", "result", ".=", "$", "this", "->", "TextLine", "(", "'Content-Type: '", ".", "$", "this", "->", "ContentType", ".", "'; charset='", ".", "$", "this", "->", "CharSet", ")", ";", "break", ";", "}", "if", "(", "$", "this", "->", "Mailer", "!=", "'mail'", ")", "{", "$", "result", ".=", "$", "this", "->", "LE", ";", "}", "return", "$", "result", ";", "}" ]
Returns the message MIME. @access public @return string
[ "Returns", "the", "message", "MIME", "." ]
df443234ad0ca10cbf91a0c0a728b256afcab1d1
https://github.com/minmb/phpmailer/blob/df443234ad0ca10cbf91a0c0a728b256afcab1d1/class.phpmailer.php#L1379-L1410
228,606
minmb/phpmailer
class.phpmailer.php
PHPMailer.AttachAll
protected function AttachAll($disposition_type, $boundary) { // Return text of body $mime = array(); $cidUniq = array(); $incl = array(); // Add all attachments foreach ($this->attachment as $attachment) { // CHECK IF IT IS A VALID DISPOSITION_FILTER if($attachment[6] == $disposition_type) { // Check for string attachment $bString = $attachment[5]; if ($bString) { $string = $attachment[0]; } else { $path = $attachment[0]; } $inclhash = md5(serialize($attachment)); if (in_array($inclhash, $incl)) { continue; } $incl[] = $inclhash; $filename = $attachment[1]; $name = $attachment[2]; $encoding = $attachment[3]; $type = $attachment[4]; $disposition = $attachment[6]; $cid = $attachment[7]; if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; } $cidUniq[$cid] = true; $mime[] = sprintf("--%s%s", $boundary, $this->LE); $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); if($disposition == 'inline') { $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); } $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); // Encode as string attachment if($bString) { $mime[] = $this->EncodeString($string, $encoding); if($this->IsError()) { return ''; } $mime[] = $this->LE.$this->LE; } else { $mime[] = $this->EncodeFile($path, $encoding); if($this->IsError()) { return ''; } $mime[] = $this->LE.$this->LE; } } } $mime[] = sprintf("--%s--%s", $boundary, $this->LE); return implode("", $mime); }
php
protected function AttachAll($disposition_type, $boundary) { // Return text of body $mime = array(); $cidUniq = array(); $incl = array(); // Add all attachments foreach ($this->attachment as $attachment) { // CHECK IF IT IS A VALID DISPOSITION_FILTER if($attachment[6] == $disposition_type) { // Check for string attachment $bString = $attachment[5]; if ($bString) { $string = $attachment[0]; } else { $path = $attachment[0]; } $inclhash = md5(serialize($attachment)); if (in_array($inclhash, $incl)) { continue; } $incl[] = $inclhash; $filename = $attachment[1]; $name = $attachment[2]; $encoding = $attachment[3]; $type = $attachment[4]; $disposition = $attachment[6]; $cid = $attachment[7]; if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; } $cidUniq[$cid] = true; $mime[] = sprintf("--%s%s", $boundary, $this->LE); $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); if($disposition == 'inline') { $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); } $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); // Encode as string attachment if($bString) { $mime[] = $this->EncodeString($string, $encoding); if($this->IsError()) { return ''; } $mime[] = $this->LE.$this->LE; } else { $mime[] = $this->EncodeFile($path, $encoding); if($this->IsError()) { return ''; } $mime[] = $this->LE.$this->LE; } } } $mime[] = sprintf("--%s--%s", $boundary, $this->LE); return implode("", $mime); }
[ "protected", "function", "AttachAll", "(", "$", "disposition_type", ",", "$", "boundary", ")", "{", "// Return text of body", "$", "mime", "=", "array", "(", ")", ";", "$", "cidUniq", "=", "array", "(", ")", ";", "$", "incl", "=", "array", "(", ")", ";", "// Add all attachments", "foreach", "(", "$", "this", "->", "attachment", "as", "$", "attachment", ")", "{", "// CHECK IF IT IS A VALID DISPOSITION_FILTER", "if", "(", "$", "attachment", "[", "6", "]", "==", "$", "disposition_type", ")", "{", "// Check for string attachment", "$", "bString", "=", "$", "attachment", "[", "5", "]", ";", "if", "(", "$", "bString", ")", "{", "$", "string", "=", "$", "attachment", "[", "0", "]", ";", "}", "else", "{", "$", "path", "=", "$", "attachment", "[", "0", "]", ";", "}", "$", "inclhash", "=", "md5", "(", "serialize", "(", "$", "attachment", ")", ")", ";", "if", "(", "in_array", "(", "$", "inclhash", ",", "$", "incl", ")", ")", "{", "continue", ";", "}", "$", "incl", "[", "]", "=", "$", "inclhash", ";", "$", "filename", "=", "$", "attachment", "[", "1", "]", ";", "$", "name", "=", "$", "attachment", "[", "2", "]", ";", "$", "encoding", "=", "$", "attachment", "[", "3", "]", ";", "$", "type", "=", "$", "attachment", "[", "4", "]", ";", "$", "disposition", "=", "$", "attachment", "[", "6", "]", ";", "$", "cid", "=", "$", "attachment", "[", "7", "]", ";", "if", "(", "$", "disposition", "==", "'inline'", "&&", "isset", "(", "$", "cidUniq", "[", "$", "cid", "]", ")", ")", "{", "continue", ";", "}", "$", "cidUniq", "[", "$", "cid", "]", "=", "true", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"--%s%s\"", ",", "$", "boundary", ",", "$", "this", "->", "LE", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"Content-Type: %s; name=\\\"%s\\\"%s\"", ",", "$", "type", ",", "$", "this", "->", "EncodeHeader", "(", "$", "this", "->", "SecureHeader", "(", "$", "name", ")", ")", ",", "$", "this", "->", "LE", ")", ";", "$", "mime", "[", "]", "=", "sprintf", "(", "\"Content-Transfer-Encoding: %s%s\"", ",", "$", "encoding", ",", "$", "this", "->", "LE", ")", ";", "if", "(", "$", "disposition", "==", "'inline'", ")", "{", "$", "mime", "[", "]", "=", "sprintf", "(", "\"Content-ID: <%s>%s\"", ",", "$", "cid", ",", "$", "this", "->", "LE", ")", ";", "}", "$", "mime", "[", "]", "=", "sprintf", "(", "\"Content-Disposition: %s; filename=\\\"%s\\\"%s\"", ",", "$", "disposition", ",", "$", "this", "->", "EncodeHeader", "(", "$", "this", "->", "SecureHeader", "(", "$", "name", ")", ")", ",", "$", "this", "->", "LE", ".", "$", "this", "->", "LE", ")", ";", "// Encode as string attachment", "if", "(", "$", "bString", ")", "{", "$", "mime", "[", "]", "=", "$", "this", "->", "EncodeString", "(", "$", "string", ",", "$", "encoding", ")", ";", "if", "(", "$", "this", "->", "IsError", "(", ")", ")", "{", "return", "''", ";", "}", "$", "mime", "[", "]", "=", "$", "this", "->", "LE", ".", "$", "this", "->", "LE", ";", "}", "else", "{", "$", "mime", "[", "]", "=", "$", "this", "->", "EncodeFile", "(", "$", "path", ",", "$", "encoding", ")", ";", "if", "(", "$", "this", "->", "IsError", "(", ")", ")", "{", "return", "''", ";", "}", "$", "mime", "[", "]", "=", "$", "this", "->", "LE", ".", "$", "this", "->", "LE", ";", "}", "}", "}", "$", "mime", "[", "]", "=", "sprintf", "(", "\"--%s--%s\"", ",", "$", "boundary", ",", "$", "this", "->", "LE", ")", ";", "return", "implode", "(", "\"\"", ",", "$", "mime", ")", ";", "}" ]
Attaches all fs, string, and binary attachments to the message. Returns an empty string on failure. @access protected @return string
[ "Attaches", "all", "fs", "string", "and", "binary", "attachments", "to", "the", "message", ".", "Returns", "an", "empty", "string", "on", "failure", "." ]
df443234ad0ca10cbf91a0c0a728b256afcab1d1
https://github.com/minmb/phpmailer/blob/df443234ad0ca10cbf91a0c0a728b256afcab1d1/class.phpmailer.php#L1684-L1744
228,607
minmb/phpmailer
class.phpmailer.php
PHPMailer.SetError
protected function SetError($msg) { $this->error_count++; if (($this->Mailer == 'smtp') and ($this->smtp !== null)) { $lasterror = $this->smtp->getError(); if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) { $msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n"; } } $this->ErrorInfo = $msg; }
php
protected function SetError($msg) { $this->error_count++; if (($this->Mailer == 'smtp') and ($this->smtp !== null)) { $lasterror = $this->smtp->getError(); if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) { $msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n"; } } $this->ErrorInfo = $msg; }
[ "protected", "function", "SetError", "(", "$", "msg", ")", "{", "$", "this", "->", "error_count", "++", ";", "if", "(", "(", "$", "this", "->", "Mailer", "==", "'smtp'", ")", "and", "(", "$", "this", "->", "smtp", "!==", "null", ")", ")", "{", "$", "lasterror", "=", "$", "this", "->", "smtp", "->", "getError", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "lasterror", ")", "and", "array_key_exists", "(", "'smtp_msg'", ",", "$", "lasterror", ")", ")", "{", "$", "msg", ".=", "'<p>'", ".", "$", "this", "->", "Lang", "(", "'smtp_error'", ")", ".", "$", "lasterror", "[", "'smtp_msg'", "]", ".", "\"</p>\\n\"", ";", "}", "}", "$", "this", "->", "ErrorInfo", "=", "$", "msg", ";", "}" ]
Adds the error message to the error container. @access protected @return void
[ "Adds", "the", "error", "message", "to", "the", "error", "container", "." ]
df443234ad0ca10cbf91a0c0a728b256afcab1d1
https://github.com/minmb/phpmailer/blob/df443234ad0ca10cbf91a0c0a728b256afcab1d1/class.phpmailer.php#L2252-L2261
228,608
minmb/phpmailer
class.phpmailer.php
PHPMailer.ServerHostname
protected function ServerHostname() { if (!empty($this->Hostname)) { $result = $this->Hostname; } elseif (isset($_SERVER['SERVER_NAME'])) { $result = $_SERVER['SERVER_NAME']; } else { $result = 'localhost.localdomain'; } return $result; }
php
protected function ServerHostname() { if (!empty($this->Hostname)) { $result = $this->Hostname; } elseif (isset($_SERVER['SERVER_NAME'])) { $result = $_SERVER['SERVER_NAME']; } else { $result = 'localhost.localdomain'; } return $result; }
[ "protected", "function", "ServerHostname", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "Hostname", ")", ")", "{", "$", "result", "=", "$", "this", "->", "Hostname", ";", "}", "elseif", "(", "isset", "(", "$", "_SERVER", "[", "'SERVER_NAME'", "]", ")", ")", "{", "$", "result", "=", "$", "_SERVER", "[", "'SERVER_NAME'", "]", ";", "}", "else", "{", "$", "result", "=", "'localhost.localdomain'", ";", "}", "return", "$", "result", ";", "}" ]
Returns the server hostname or 'localhost.localdomain' if unknown. @access protected @return string
[ "Returns", "the", "server", "hostname", "or", "localhost", ".", "localdomain", "if", "unknown", "." ]
df443234ad0ca10cbf91a0c0a728b256afcab1d1
https://github.com/minmb/phpmailer/blob/df443234ad0ca10cbf91a0c0a728b256afcab1d1/class.phpmailer.php#L2284-L2294
228,609
pear/Net_LDAP2
Net/LDAP2/LDIF.php
Net_LDAP2_LDIF.write_version
public function write_version() { $this->_version_written = true; if (!is_null($this->version())) { return $this->writeLine('version: '.$this->version().PHP_EOL, 'Net_LDAP2_LDIF error: unable to write version'); } }
php
public function write_version() { $this->_version_written = true; if (!is_null($this->version())) { return $this->writeLine('version: '.$this->version().PHP_EOL, 'Net_LDAP2_LDIF error: unable to write version'); } }
[ "public", "function", "write_version", "(", ")", "{", "$", "this", "->", "_version_written", "=", "true", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "version", "(", ")", ")", ")", "{", "return", "$", "this", "->", "writeLine", "(", "'version: '", ".", "$", "this", "->", "version", "(", ")", ".", "PHP_EOL", ",", "'Net_LDAP2_LDIF error: unable to write version'", ")", ";", "}", "}" ]
Write version to LDIF If the object's version is defined, this method allows to explicitely write the version before an entry is written. If not called explicitely, it gets called automatically when writing the first entry. @return void
[ "Write", "version", "to", "LDIF" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/LDIF.php#L428-L434
228,610
pear/Net_LDAP2
Net/LDAP2/LDIF.php
Net_LDAP2_LDIF.version
public function version($version = null) { if ($version !== null) { if ($version != 1) { $this->dropError('Net_LDAP2_LDIF error: illegal LDIF version set'); } else { $this->_options['version'] = $version; } } return $this->_options['version']; }
php
public function version($version = null) { if ($version !== null) { if ($version != 1) { $this->dropError('Net_LDAP2_LDIF error: illegal LDIF version set'); } else { $this->_options['version'] = $version; } } return $this->_options['version']; }
[ "public", "function", "version", "(", "$", "version", "=", "null", ")", "{", "if", "(", "$", "version", "!==", "null", ")", "{", "if", "(", "$", "version", "!=", "1", ")", "{", "$", "this", "->", "dropError", "(", "'Net_LDAP2_LDIF error: illegal LDIF version set'", ")", ";", "}", "else", "{", "$", "this", "->", "_options", "[", "'version'", "]", "=", "$", "version", ";", "}", "}", "return", "$", "this", "->", "_options", "[", "'version'", "]", ";", "}" ]
Get or set LDIF version If called without arguments it returns the version of the LDIF file or NULL if no version has been set. If called with an argument it sets the LDIF version to VERSION. According to RFC 2849 currently the only legal value for VERSION is 1. @param int $version (optional) LDIF version to set @return int
[ "Get", "or", "set", "LDIF", "version" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/LDIF.php#L447-L457
228,611
pear/Net_LDAP2
Net/LDAP2/LDIF.php
Net_LDAP2_LDIF.&
public function &handle() { if (!is_resource($this->_FH)) { $this->dropError('Net_LDAP2_LDIF error: invalid file resource'); $null = null; return $null; } else { return $this->_FH; } }
php
public function &handle() { if (!is_resource($this->_FH)) { $this->dropError('Net_LDAP2_LDIF error: invalid file resource'); $null = null; return $null; } else { return $this->_FH; } }
[ "public", "function", "&", "handle", "(", ")", "{", "if", "(", "!", "is_resource", "(", "$", "this", "->", "_FH", ")", ")", "{", "$", "this", "->", "dropError", "(", "'Net_LDAP2_LDIF error: invalid file resource'", ")", ";", "$", "null", "=", "null", ";", "return", "$", "null", ";", "}", "else", "{", "return", "$", "this", "->", "_FH", ";", "}", "}" ]
Returns the file handle the Net_LDAP2_LDIF object reads from or writes to. You can, for example, use this to fetch the content of the LDIF file yourself @return null|resource
[ "Returns", "the", "file", "handle", "the", "Net_LDAP2_LDIF", "object", "reads", "from", "or", "writes", "to", "." ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/LDIF.php#L466-L475
228,612
pear/Net_LDAP2
Net/LDAP2/LDIF.php
Net_LDAP2_LDIF.error
public function error($as_string = false) { if (Net_LDAP2::isError($this->_error['error'])) { return ($as_string)? $this->_error['error']->getMessage() : $this->_error['error']; } else { return false; } }
php
public function error($as_string = false) { if (Net_LDAP2::isError($this->_error['error'])) { return ($as_string)? $this->_error['error']->getMessage() : $this->_error['error']; } else { return false; } }
[ "public", "function", "error", "(", "$", "as_string", "=", "false", ")", "{", "if", "(", "Net_LDAP2", "::", "isError", "(", "$", "this", "->", "_error", "[", "'error'", "]", ")", ")", "{", "return", "(", "$", "as_string", ")", "?", "$", "this", "->", "_error", "[", "'error'", "]", "->", "getMessage", "(", ")", ":", "$", "this", "->", "_error", "[", "'error'", "]", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Returns last error message if error was found. Example: <code> $ldif->someAction(); if ($ldif->error()) { echo "Error: ".$ldif->error()." at input line: ".$ldif->error_lines(); } </code> @param boolean $as_string If set to true, only the message is returned @return false|Net_LDAP2_Error
[ "Returns", "last", "error", "message", "if", "error", "was", "found", "." ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/LDIF.php#L514-L521
228,613
pear/Net_LDAP2
Net/LDAP2/LDIF.php
Net_LDAP2_LDIF.parseLines
public function parseLines($lines) { // parse lines into an array of attributes and build the entry $attributes = array(); $dn = false; foreach ($lines as $line) { if (preg_match('/^(\w+(;binary)?)(:|::|:<)\s(.+)$/', $line, $matches)) { $attr =& $matches[1] . $matches[2]; $delim =& $matches[3]; $data =& $matches[4]; if ($delim == ':') { // normal data $attributes[$attr][] = $data; } elseif ($delim == '::') { // base64 data $attributes[$attr][] = base64_decode($data); } elseif ($delim == ':<') { // file inclusion // TODO: Is this the job of the LDAP-client or the server? $this->dropError('File inclusions are currently not supported'); //$attributes[$attr][] = ...; } else { // since the pattern above, the delimeter cannot be something else. $this->dropError('Net_LDAP2_LDIF parsing error: invalid syntax at parsing entry line: '.$line); continue; } if (strtolower($attr) == 'dn') { // DN line detected $dn = $attributes[$attr][0]; // save possibly decoded DN unset($attributes[$attr]); // remove wrongly added "dn: " attribute } } else { // line not in "attr: value" format -> ignore // maybe we should rise an error here, but this should be covered by // next_lines() already. A problem arises, if users try to feed data of // several entries to this method - the resulting entry will // get wrong attributes. However, this is already mentioned in the // methods documentation above. } } if (false === $dn) { $this->dropError('Net_LDAP2_LDIF parsing error: unable to detect DN for entry'); return false; } else { $newentry = Net_LDAP2_Entry::createFresh($dn, $attributes); return $newentry; } }
php
public function parseLines($lines) { // parse lines into an array of attributes and build the entry $attributes = array(); $dn = false; foreach ($lines as $line) { if (preg_match('/^(\w+(;binary)?)(:|::|:<)\s(.+)$/', $line, $matches)) { $attr =& $matches[1] . $matches[2]; $delim =& $matches[3]; $data =& $matches[4]; if ($delim == ':') { // normal data $attributes[$attr][] = $data; } elseif ($delim == '::') { // base64 data $attributes[$attr][] = base64_decode($data); } elseif ($delim == ':<') { // file inclusion // TODO: Is this the job of the LDAP-client or the server? $this->dropError('File inclusions are currently not supported'); //$attributes[$attr][] = ...; } else { // since the pattern above, the delimeter cannot be something else. $this->dropError('Net_LDAP2_LDIF parsing error: invalid syntax at parsing entry line: '.$line); continue; } if (strtolower($attr) == 'dn') { // DN line detected $dn = $attributes[$attr][0]; // save possibly decoded DN unset($attributes[$attr]); // remove wrongly added "dn: " attribute } } else { // line not in "attr: value" format -> ignore // maybe we should rise an error here, but this should be covered by // next_lines() already. A problem arises, if users try to feed data of // several entries to this method - the resulting entry will // get wrong attributes. However, this is already mentioned in the // methods documentation above. } } if (false === $dn) { $this->dropError('Net_LDAP2_LDIF parsing error: unable to detect DN for entry'); return false; } else { $newentry = Net_LDAP2_Entry::createFresh($dn, $attributes); return $newentry; } }
[ "public", "function", "parseLines", "(", "$", "lines", ")", "{", "// parse lines into an array of attributes and build the entry", "$", "attributes", "=", "array", "(", ")", ";", "$", "dn", "=", "false", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "if", "(", "preg_match", "(", "'/^(\\w+(;binary)?)(:|::|:<)\\s(.+)$/'", ",", "$", "line", ",", "$", "matches", ")", ")", "{", "$", "attr", "=", "&", "$", "matches", "[", "1", "]", ".", "$", "matches", "[", "2", "]", ";", "$", "delim", "=", "&", "$", "matches", "[", "3", "]", ";", "$", "data", "=", "&", "$", "matches", "[", "4", "]", ";", "if", "(", "$", "delim", "==", "':'", ")", "{", "// normal data", "$", "attributes", "[", "$", "attr", "]", "[", "]", "=", "$", "data", ";", "}", "elseif", "(", "$", "delim", "==", "'::'", ")", "{", "// base64 data", "$", "attributes", "[", "$", "attr", "]", "[", "]", "=", "base64_decode", "(", "$", "data", ")", ";", "}", "elseif", "(", "$", "delim", "==", "':<'", ")", "{", "// file inclusion", "// TODO: Is this the job of the LDAP-client or the server?", "$", "this", "->", "dropError", "(", "'File inclusions are currently not supported'", ")", ";", "//$attributes[$attr][] = ...;", "}", "else", "{", "// since the pattern above, the delimeter cannot be something else.", "$", "this", "->", "dropError", "(", "'Net_LDAP2_LDIF parsing error: invalid syntax at parsing entry line: '", ".", "$", "line", ")", ";", "continue", ";", "}", "if", "(", "strtolower", "(", "$", "attr", ")", "==", "'dn'", ")", "{", "// DN line detected", "$", "dn", "=", "$", "attributes", "[", "$", "attr", "]", "[", "0", "]", ";", "// save possibly decoded DN", "unset", "(", "$", "attributes", "[", "$", "attr", "]", ")", ";", "// remove wrongly added \"dn: \" attribute", "}", "}", "else", "{", "// line not in \"attr: value\" format -> ignore", "// maybe we should rise an error here, but this should be covered by", "// next_lines() already. A problem arises, if users try to feed data of", "// several entries to this method - the resulting entry will", "// get wrong attributes. However, this is already mentioned in the", "// methods documentation above.", "}", "}", "if", "(", "false", "===", "$", "dn", ")", "{", "$", "this", "->", "dropError", "(", "'Net_LDAP2_LDIF parsing error: unable to detect DN for entry'", ")", ";", "return", "false", ";", "}", "else", "{", "$", "newentry", "=", "Net_LDAP2_Entry", "::", "createFresh", "(", "$", "dn", ",", "$", "attributes", ")", ";", "return", "$", "newentry", ";", "}", "}" ]
Parse LDIF lines of one entry into an Net_LDAP2_Entry object @param array $lines LDIF lines for one entry @return Net_LDAP2_Entry|false Net_LDAP2_Entry object for those lines @todo what about file inclusions and urls? "jpegphoto:< file:///usr/local/directory/photos/fiona.jpg"
[ "Parse", "LDIF", "lines", "of", "one", "entry", "into", "an", "Net_LDAP2_Entry", "object" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/LDIF.php#L554-L604
228,614
pear/Net_LDAP2
Net/LDAP2/LDIF.php
Net_LDAP2_LDIF.convertAttribute
protected function convertAttribute($attr_name, $attr_value) { // Handle empty attribute or process if (strlen($attr_value) == 0) { $attr_value = " "; } else { $base64 = false; // ASCII-chars that are NOT safe for the // start and for being inside the value. // These are the int values of those chars. $unsafe_init = array(0, 10, 13, 32, 58, 60); $unsafe = array(0, 10, 13); // Test for illegal init char $init_ord = ord(substr($attr_value, 0, 1)); if ($init_ord > 127 || in_array($init_ord, $unsafe_init)) { $base64 = true; } // Test for illegal content char for ($i = 0; $i < strlen($attr_value); $i++) { $char_ord = ord(substr($attr_value, $i, 1)); if ($char_ord > 127 || in_array($char_ord, $unsafe)) { $base64 = true; } } // Test for ending space if (substr($attr_value, -1) == ' ') { $base64 = true; } // If converting is needed, do it // Either we have some special chars or a matching "raw" regex if ($base64 || ($this->_options['raw'] && preg_match($this->_options['raw'], $attr_name))) { $attr_name .= ':'; $attr_value = base64_encode($attr_value); } // Lowercase attr names if requested if ($this->_options['lowercase']) $attr_name = strtolower($attr_name); // Handle line wrapping if ($this->_options['wrap'] > 40 && strlen($attr_value) > $this->_options['wrap']) { $attr_value = wordwrap($attr_value, $this->_options['wrap'], PHP_EOL." ", true); } } return $attr_name.': '.$attr_value; }
php
protected function convertAttribute($attr_name, $attr_value) { // Handle empty attribute or process if (strlen($attr_value) == 0) { $attr_value = " "; } else { $base64 = false; // ASCII-chars that are NOT safe for the // start and for being inside the value. // These are the int values of those chars. $unsafe_init = array(0, 10, 13, 32, 58, 60); $unsafe = array(0, 10, 13); // Test for illegal init char $init_ord = ord(substr($attr_value, 0, 1)); if ($init_ord > 127 || in_array($init_ord, $unsafe_init)) { $base64 = true; } // Test for illegal content char for ($i = 0; $i < strlen($attr_value); $i++) { $char_ord = ord(substr($attr_value, $i, 1)); if ($char_ord > 127 || in_array($char_ord, $unsafe)) { $base64 = true; } } // Test for ending space if (substr($attr_value, -1) == ' ') { $base64 = true; } // If converting is needed, do it // Either we have some special chars or a matching "raw" regex if ($base64 || ($this->_options['raw'] && preg_match($this->_options['raw'], $attr_name))) { $attr_name .= ':'; $attr_value = base64_encode($attr_value); } // Lowercase attr names if requested if ($this->_options['lowercase']) $attr_name = strtolower($attr_name); // Handle line wrapping if ($this->_options['wrap'] > 40 && strlen($attr_value) > $this->_options['wrap']) { $attr_value = wordwrap($attr_value, $this->_options['wrap'], PHP_EOL." ", true); } } return $attr_name.': '.$attr_value; }
[ "protected", "function", "convertAttribute", "(", "$", "attr_name", ",", "$", "attr_value", ")", "{", "// Handle empty attribute or process", "if", "(", "strlen", "(", "$", "attr_value", ")", "==", "0", ")", "{", "$", "attr_value", "=", "\" \"", ";", "}", "else", "{", "$", "base64", "=", "false", ";", "// ASCII-chars that are NOT safe for the", "// start and for being inside the value.", "// These are the int values of those chars.", "$", "unsafe_init", "=", "array", "(", "0", ",", "10", ",", "13", ",", "32", ",", "58", ",", "60", ")", ";", "$", "unsafe", "=", "array", "(", "0", ",", "10", ",", "13", ")", ";", "// Test for illegal init char", "$", "init_ord", "=", "ord", "(", "substr", "(", "$", "attr_value", ",", "0", ",", "1", ")", ")", ";", "if", "(", "$", "init_ord", ">", "127", "||", "in_array", "(", "$", "init_ord", ",", "$", "unsafe_init", ")", ")", "{", "$", "base64", "=", "true", ";", "}", "// Test for illegal content char", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "attr_value", ")", ";", "$", "i", "++", ")", "{", "$", "char_ord", "=", "ord", "(", "substr", "(", "$", "attr_value", ",", "$", "i", ",", "1", ")", ")", ";", "if", "(", "$", "char_ord", ">", "127", "||", "in_array", "(", "$", "char_ord", ",", "$", "unsafe", ")", ")", "{", "$", "base64", "=", "true", ";", "}", "}", "// Test for ending space", "if", "(", "substr", "(", "$", "attr_value", ",", "-", "1", ")", "==", "' '", ")", "{", "$", "base64", "=", "true", ";", "}", "// If converting is needed, do it", "// Either we have some special chars or a matching \"raw\" regex", "if", "(", "$", "base64", "||", "(", "$", "this", "->", "_options", "[", "'raw'", "]", "&&", "preg_match", "(", "$", "this", "->", "_options", "[", "'raw'", "]", ",", "$", "attr_name", ")", ")", ")", "{", "$", "attr_name", ".=", "':'", ";", "$", "attr_value", "=", "base64_encode", "(", "$", "attr_value", ")", ";", "}", "// Lowercase attr names if requested", "if", "(", "$", "this", "->", "_options", "[", "'lowercase'", "]", ")", "$", "attr_name", "=", "strtolower", "(", "$", "attr_name", ")", ";", "// Handle line wrapping", "if", "(", "$", "this", "->", "_options", "[", "'wrap'", "]", ">", "40", "&&", "strlen", "(", "$", "attr_value", ")", ">", "$", "this", "->", "_options", "[", "'wrap'", "]", ")", "{", "$", "attr_value", "=", "wordwrap", "(", "$", "attr_value", ",", "$", "this", "->", "_options", "[", "'wrap'", "]", ",", "PHP_EOL", ".", "\" \"", ",", "true", ")", ";", "}", "}", "return", "$", "attr_name", ".", "': '", ".", "$", "attr_value", ";", "}" ]
Convert an attribute and value to LDIF string representation It honors correct encoding of values according to RFC 2849. Line wrapping will occur at the configured maximum but only if the value is greater than 40 chars. @param string $attr_name Name of the attribute @param string $attr_value Value of the attribute @access protected @return string LDIF string for that attribute and value
[ "Convert", "an", "attribute", "and", "value", "to", "LDIF", "string", "representation" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/LDIF.php#L738-L787
228,615
pear/Net_LDAP2
Net/LDAP2/LDIF.php
Net_LDAP2_LDIF.convertDN
protected function convertDN($dn) { $base64 = false; // ASCII-chars that are NOT safe for the // start and for being inside the dn. // These are the int values of those chars. $unsafe_init = array(0, 10, 13, 32, 58, 60); $unsafe = array(0, 10, 13); // Test for illegal init char $init_ord = ord(substr($dn, 0, 1)); if ($init_ord >= 127 || in_array($init_ord, $unsafe_init)) { $base64 = true; } // Test for illegal content char for ($i = 0; $i < strlen($dn); $i++) { $char = substr($dn, $i, 1); if (ord($char) >= 127 || in_array($init_ord, $unsafe)) { $base64 = true; } } // Test for ending space if (substr($dn, -1) == ' ') { $base64 = true; } // if converting is needed, do it return ($base64)? 'dn:: '.base64_encode($dn) : 'dn: '.$dn; }
php
protected function convertDN($dn) { $base64 = false; // ASCII-chars that are NOT safe for the // start and for being inside the dn. // These are the int values of those chars. $unsafe_init = array(0, 10, 13, 32, 58, 60); $unsafe = array(0, 10, 13); // Test for illegal init char $init_ord = ord(substr($dn, 0, 1)); if ($init_ord >= 127 || in_array($init_ord, $unsafe_init)) { $base64 = true; } // Test for illegal content char for ($i = 0; $i < strlen($dn); $i++) { $char = substr($dn, $i, 1); if (ord($char) >= 127 || in_array($init_ord, $unsafe)) { $base64 = true; } } // Test for ending space if (substr($dn, -1) == ' ') { $base64 = true; } // if converting is needed, do it return ($base64)? 'dn:: '.base64_encode($dn) : 'dn: '.$dn; }
[ "protected", "function", "convertDN", "(", "$", "dn", ")", "{", "$", "base64", "=", "false", ";", "// ASCII-chars that are NOT safe for the", "// start and for being inside the dn.", "// These are the int values of those chars.", "$", "unsafe_init", "=", "array", "(", "0", ",", "10", ",", "13", ",", "32", ",", "58", ",", "60", ")", ";", "$", "unsafe", "=", "array", "(", "0", ",", "10", ",", "13", ")", ";", "// Test for illegal init char", "$", "init_ord", "=", "ord", "(", "substr", "(", "$", "dn", ",", "0", ",", "1", ")", ")", ";", "if", "(", "$", "init_ord", ">=", "127", "||", "in_array", "(", "$", "init_ord", ",", "$", "unsafe_init", ")", ")", "{", "$", "base64", "=", "true", ";", "}", "// Test for illegal content char", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "dn", ")", ";", "$", "i", "++", ")", "{", "$", "char", "=", "substr", "(", "$", "dn", ",", "$", "i", ",", "1", ")", ";", "if", "(", "ord", "(", "$", "char", ")", ">=", "127", "||", "in_array", "(", "$", "init_ord", ",", "$", "unsafe", ")", ")", "{", "$", "base64", "=", "true", ";", "}", "}", "// Test for ending space", "if", "(", "substr", "(", "$", "dn", ",", "-", "1", ")", "==", "' '", ")", "{", "$", "base64", "=", "true", ";", "}", "// if converting is needed, do it", "return", "(", "$", "base64", ")", "?", "'dn:: '", ".", "base64_encode", "(", "$", "dn", ")", ":", "'dn: '", ".", "$", "dn", ";", "}" ]
Convert an entries DN to LDIF string representation It honors correct encoding of values according to RFC 2849. @param string $dn UTF8-Encoded DN @access protected @return string LDIF string for that DN @todo I am not sure, if the UTF8 stuff is correctly handled right now
[ "Convert", "an", "entries", "DN", "to", "LDIF", "string", "representation" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/LDIF.php#L800-L830
228,616
pear/Net_LDAP2
Net/LDAP2/LDIF.php
Net_LDAP2_LDIF.writeAttribute
protected function writeAttribute($attr_name, $attr_values) { // write out attribute content if (!is_array($attr_values)) { $attr_values = array($attr_values); } foreach ($attr_values as $attr_val) { $line = $this->convertAttribute($attr_name, $attr_val).PHP_EOL; $this->writeLine($line, 'Net_LDAP2_LDIF error: unable to write attribute '.$attr_name.' of entry '.$this->_entrynum); } }
php
protected function writeAttribute($attr_name, $attr_values) { // write out attribute content if (!is_array($attr_values)) { $attr_values = array($attr_values); } foreach ($attr_values as $attr_val) { $line = $this->convertAttribute($attr_name, $attr_val).PHP_EOL; $this->writeLine($line, 'Net_LDAP2_LDIF error: unable to write attribute '.$attr_name.' of entry '.$this->_entrynum); } }
[ "protected", "function", "writeAttribute", "(", "$", "attr_name", ",", "$", "attr_values", ")", "{", "// write out attribute content", "if", "(", "!", "is_array", "(", "$", "attr_values", ")", ")", "{", "$", "attr_values", "=", "array", "(", "$", "attr_values", ")", ";", "}", "foreach", "(", "$", "attr_values", "as", "$", "attr_val", ")", "{", "$", "line", "=", "$", "this", "->", "convertAttribute", "(", "$", "attr_name", ",", "$", "attr_val", ")", ".", "PHP_EOL", ";", "$", "this", "->", "writeLine", "(", "$", "line", ",", "'Net_LDAP2_LDIF error: unable to write attribute '", ".", "$", "attr_name", ".", "' of entry '", ".", "$", "this", "->", "_entrynum", ")", ";", "}", "}" ]
Writes an attribute to the filehandle @param string $attr_name Name of the attribute @param string|array $attr_values Single attribute value or array with attribute values @access protected @return void
[ "Writes", "an", "attribute", "to", "the", "filehandle" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/LDIF.php#L841-L851
228,617
pear/Net_LDAP2
Net/LDAP2/LDIF.php
Net_LDAP2_LDIF.writeDN
protected function writeDN($dn) { // prepare DN if ($this->_options['encode'] == 'base64') { $dn = $this->convertDN($dn).PHP_EOL; } elseif ($this->_options['encode'] == 'canonical') { $dn = Net_LDAP2_Util::canonical_dn($dn, array('casefold' => 'none')).PHP_EOL; } else { $dn = $dn.PHP_EOL; } $this->writeLine($dn, 'Net_LDAP2_LDIF error: unable to write DN of entry '.$this->_entrynum); }
php
protected function writeDN($dn) { // prepare DN if ($this->_options['encode'] == 'base64') { $dn = $this->convertDN($dn).PHP_EOL; } elseif ($this->_options['encode'] == 'canonical') { $dn = Net_LDAP2_Util::canonical_dn($dn, array('casefold' => 'none')).PHP_EOL; } else { $dn = $dn.PHP_EOL; } $this->writeLine($dn, 'Net_LDAP2_LDIF error: unable to write DN of entry '.$this->_entrynum); }
[ "protected", "function", "writeDN", "(", "$", "dn", ")", "{", "// prepare DN", "if", "(", "$", "this", "->", "_options", "[", "'encode'", "]", "==", "'base64'", ")", "{", "$", "dn", "=", "$", "this", "->", "convertDN", "(", "$", "dn", ")", ".", "PHP_EOL", ";", "}", "elseif", "(", "$", "this", "->", "_options", "[", "'encode'", "]", "==", "'canonical'", ")", "{", "$", "dn", "=", "Net_LDAP2_Util", "::", "canonical_dn", "(", "$", "dn", ",", "array", "(", "'casefold'", "=>", "'none'", ")", ")", ".", "PHP_EOL", ";", "}", "else", "{", "$", "dn", "=", "$", "dn", ".", "PHP_EOL", ";", "}", "$", "this", "->", "writeLine", "(", "$", "dn", ",", "'Net_LDAP2_LDIF error: unable to write DN of entry '", ".", "$", "this", "->", "_entrynum", ")", ";", "}" ]
Writes a DN to the filehandle @param string $dn DN to write @access protected @return void
[ "Writes", "a", "DN", "to", "the", "filehandle" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/LDIF.php#L861-L872
228,618
pear/Net_LDAP2
Net/LDAP2/LDIF.php
Net_LDAP2_LDIF.writeLine
protected function writeLine($line, $error = 'Net_LDAP2_LDIF error: unable to write to filehandle') { if (is_resource($this->handle()) && fwrite($this->handle(), $line, strlen($line)) === false) { $this->dropError($error); return false; } else { return true; } }
php
protected function writeLine($line, $error = 'Net_LDAP2_LDIF error: unable to write to filehandle') { if (is_resource($this->handle()) && fwrite($this->handle(), $line, strlen($line)) === false) { $this->dropError($error); return false; } else { return true; } }
[ "protected", "function", "writeLine", "(", "$", "line", ",", "$", "error", "=", "'Net_LDAP2_LDIF error: unable to write to filehandle'", ")", "{", "if", "(", "is_resource", "(", "$", "this", "->", "handle", "(", ")", ")", "&&", "fwrite", "(", "$", "this", "->", "handle", "(", ")", ",", "$", "line", ",", "strlen", "(", "$", "line", ")", ")", "===", "false", ")", "{", "$", "this", "->", "dropError", "(", "$", "error", ")", ";", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
Just write an arbitary line to the filehandle @param string $line Content to write @param string $error If error occurs, drop this message @access protected @return true|false
[ "Just", "write", "an", "arbitary", "line", "to", "the", "filehandle" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/LDIF.php#L894-L902
228,619
pear/Net_LDAP2
Net/LDAP2/LDIF.php
Net_LDAP2_LDIF.dropError
protected function dropError($msg, $line = null) { $this->_error['error'] = new Net_LDAP2_Error($msg); if ($line !== null) $this->_error['line'] = $line; if ($this->_options['onerror'] == 'die') { die($msg.PHP_EOL); } elseif ($this->_options['onerror'] == 'warn') { echo $msg.PHP_EOL; } }
php
protected function dropError($msg, $line = null) { $this->_error['error'] = new Net_LDAP2_Error($msg); if ($line !== null) $this->_error['line'] = $line; if ($this->_options['onerror'] == 'die') { die($msg.PHP_EOL); } elseif ($this->_options['onerror'] == 'warn') { echo $msg.PHP_EOL; } }
[ "protected", "function", "dropError", "(", "$", "msg", ",", "$", "line", "=", "null", ")", "{", "$", "this", "->", "_error", "[", "'error'", "]", "=", "new", "Net_LDAP2_Error", "(", "$", "msg", ")", ";", "if", "(", "$", "line", "!==", "null", ")", "$", "this", "->", "_error", "[", "'line'", "]", "=", "$", "line", ";", "if", "(", "$", "this", "->", "_options", "[", "'onerror'", "]", "==", "'die'", ")", "{", "die", "(", "$", "msg", ".", "PHP_EOL", ")", ";", "}", "elseif", "(", "$", "this", "->", "_options", "[", "'onerror'", "]", "==", "'warn'", ")", "{", "echo", "$", "msg", ".", "PHP_EOL", ";", "}", "}" ]
Optionally raises an error and pushes the error on the error cache @param string $msg Errortext @param int $line Line in the LDIF that caused the error @access protected @return void
[ "Optionally", "raises", "an", "error", "and", "pushes", "the", "error", "on", "the", "error", "cache" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/LDIF.php#L913-L923
228,620
mariano/disque-php
src/Connection/Response/ErrorResponse.php
ErrorResponse.getExceptionClass
private function getExceptionClass($error) { $errors = [ 'PAUSED' => QueuePausedResponseException::class ]; $exceptionClass = ResponseException::class; list($errorCode) = explode(" ", $error); if (!empty($errorCode) && isset($errors[$errorCode])) { $exceptionClass = $errors[$errorCode]; } return $exceptionClass; }
php
private function getExceptionClass($error) { $errors = [ 'PAUSED' => QueuePausedResponseException::class ]; $exceptionClass = ResponseException::class; list($errorCode) = explode(" ", $error); if (!empty($errorCode) && isset($errors[$errorCode])) { $exceptionClass = $errors[$errorCode]; } return $exceptionClass; }
[ "private", "function", "getExceptionClass", "(", "$", "error", ")", "{", "$", "errors", "=", "[", "'PAUSED'", "=>", "QueuePausedResponseException", "::", "class", "]", ";", "$", "exceptionClass", "=", "ResponseException", "::", "class", ";", "list", "(", "$", "errorCode", ")", "=", "explode", "(", "\" \"", ",", "$", "error", ")", ";", "if", "(", "!", "empty", "(", "$", "errorCode", ")", "&&", "isset", "(", "$", "errors", "[", "$", "errorCode", "]", ")", ")", "{", "$", "exceptionClass", "=", "$", "errors", "[", "$", "errorCode", "]", ";", "}", "return", "$", "exceptionClass", ";", "}" ]
Creates ResponseException based off error @param string $error Error @return string Class Name
[ "Creates", "ResponseException", "based", "off", "error" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Connection/Response/ErrorResponse.php#L24-L35
228,621
sop/crypto-types
lib/CryptoTypes/Asymmetric/PublicKeyInfo.php
PublicKeyInfo.publicKey
public function publicKey(): PublicKey { $algo = $this->algorithmIdentifier(); switch ($algo->oid()) { // RSA case AlgorithmIdentifier::OID_RSA_ENCRYPTION: return RSA\RSAPublicKey::fromDER($this->_publicKeyData); // elliptic curve case AlgorithmIdentifier::OID_EC_PUBLIC_KEY: if (!$algo instanceof ECPublicKeyAlgorithmIdentifier) { throw new \UnexpectedValueException("Not an EC algorithm."); } // ECPoint is directly mapped into public key data return new EC\ECPublicKey($this->_publicKeyData, $algo->namedCurve()); } throw new \RuntimeException( "Public key " . $algo->name() . " not supported."); }
php
public function publicKey(): PublicKey { $algo = $this->algorithmIdentifier(); switch ($algo->oid()) { // RSA case AlgorithmIdentifier::OID_RSA_ENCRYPTION: return RSA\RSAPublicKey::fromDER($this->_publicKeyData); // elliptic curve case AlgorithmIdentifier::OID_EC_PUBLIC_KEY: if (!$algo instanceof ECPublicKeyAlgorithmIdentifier) { throw new \UnexpectedValueException("Not an EC algorithm."); } // ECPoint is directly mapped into public key data return new EC\ECPublicKey($this->_publicKeyData, $algo->namedCurve()); } throw new \RuntimeException( "Public key " . $algo->name() . " not supported."); }
[ "public", "function", "publicKey", "(", ")", ":", "PublicKey", "{", "$", "algo", "=", "$", "this", "->", "algorithmIdentifier", "(", ")", ";", "switch", "(", "$", "algo", "->", "oid", "(", ")", ")", "{", "// RSA", "case", "AlgorithmIdentifier", "::", "OID_RSA_ENCRYPTION", ":", "return", "RSA", "\\", "RSAPublicKey", "::", "fromDER", "(", "$", "this", "->", "_publicKeyData", ")", ";", "// elliptic curve", "case", "AlgorithmIdentifier", "::", "OID_EC_PUBLIC_KEY", ":", "if", "(", "!", "$", "algo", "instanceof", "ECPublicKeyAlgorithmIdentifier", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Not an EC algorithm.\"", ")", ";", "}", "// ECPoint is directly mapped into public key data", "return", "new", "EC", "\\", "ECPublicKey", "(", "$", "this", "->", "_publicKeyData", ",", "$", "algo", "->", "namedCurve", "(", ")", ")", ";", "}", "throw", "new", "\\", "RuntimeException", "(", "\"Public key \"", ".", "$", "algo", "->", "name", "(", ")", ".", "\" not supported.\"", ")", ";", "}" ]
Get public key. @throws \RuntimeException @return PublicKey
[ "Get", "public", "key", "." ]
1d36250a110b07300aeb003a20aeaadfc6445501
https://github.com/sop/crypto-types/blob/1d36250a110b07300aeb003a20aeaadfc6445501/lib/CryptoTypes/Asymmetric/PublicKeyInfo.php#L130-L148
228,622
sop/crypto-types
lib/CryptoTypes/Asymmetric/PublicKeyInfo.php
PublicKeyInfo.keyIdentifier64
public function keyIdentifier64(): string { $id = substr($this->keyIdentifier(), -8); $c = (ord($id[0]) & 0x0f) | 0x40; $id[0] = chr($c); return $id; }
php
public function keyIdentifier64(): string { $id = substr($this->keyIdentifier(), -8); $c = (ord($id[0]) & 0x0f) | 0x40; $id[0] = chr($c); return $id; }
[ "public", "function", "keyIdentifier64", "(", ")", ":", "string", "{", "$", "id", "=", "substr", "(", "$", "this", "->", "keyIdentifier", "(", ")", ",", "-", "8", ")", ";", "$", "c", "=", "(", "ord", "(", "$", "id", "[", "0", "]", ")", "&", "0x0f", ")", "|", "0x40", ";", "$", "id", "[", "0", "]", "=", "chr", "(", "$", "c", ")", ";", "return", "$", "id", ";", "}" ]
Get key identifier using method 2 as described by RFC 5280. @link https://tools.ietf.org/html/rfc5280#section-4.2.1.2 @return string 8 bytes (64 bits) long identifier
[ "Get", "key", "identifier", "using", "method", "2", "as", "described", "by", "RFC", "5280", "." ]
1d36250a110b07300aeb003a20aeaadfc6445501
https://github.com/sop/crypto-types/blob/1d36250a110b07300aeb003a20aeaadfc6445501/lib/CryptoTypes/Asymmetric/PublicKeyInfo.php#L167-L173
228,623
mlaphp/mlaphp
src/Mlaphp/Di.php
Di.set
public function set($name, $callable) { $name = ltrim($name, '\\'); $this->callables[$name] = $callable; unset($this->instances[$name]); }
php
public function set($name, $callable) { $name = ltrim($name, '\\'); $this->callables[$name] = $callable; unset($this->instances[$name]); }
[ "public", "function", "set", "(", "$", "name", ",", "$", "callable", ")", "{", "$", "name", "=", "ltrim", "(", "$", "name", ",", "'\\\\'", ")", ";", "$", "this", "->", "callables", "[", "$", "name", "]", "=", "$", "callable", ";", "unset", "(", "$", "this", "->", "instances", "[", "$", "name", "]", ")", ";", "}" ]
Sets a callable to create an object by name; removes any existing shared instance under that name. @param string $name The object name. @param callable $callable A callable that returns an object. @return null
[ "Sets", "a", "callable", "to", "create", "an", "object", "by", "name", ";", "removes", "any", "existing", "shared", "instance", "under", "that", "name", "." ]
c0c90e7217c598c82bb65e5304e8076da381c1f8
https://github.com/mlaphp/mlaphp/blob/c0c90e7217c598c82bb65e5304e8076da381c1f8/src/Mlaphp/Di.php#L104-L109
228,624
mlaphp/mlaphp
src/Mlaphp/Di.php
Di.get
public function get($name) { $name = ltrim($name, '\\'); if (! isset($this->instances[$name])) { $this->instances[$name] = $this->newInstance($name); } return $this->instances[$name]; }
php
public function get($name) { $name = ltrim($name, '\\'); if (! isset($this->instances[$name])) { $this->instances[$name] = $this->newInstance($name); } return $this->instances[$name]; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "$", "name", "=", "ltrim", "(", "$", "name", ",", "'\\\\'", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "instances", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "instances", "[", "$", "name", "]", "=", "$", "this", "->", "newInstance", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "instances", "[", "$", "name", "]", ";", "}" ]
Gets a shared instance by object name; if it has not been created yet, its callable will be invoked and the instance will be retained. @param string $name The name of the shared instance to retrieve. @return object The shared object instance.
[ "Gets", "a", "shared", "instance", "by", "object", "name", ";", "if", "it", "has", "not", "been", "created", "yet", "its", "callable", "will", "be", "invoked", "and", "the", "instance", "will", "be", "retained", "." ]
c0c90e7217c598c82bb65e5304e8076da381c1f8
https://github.com/mlaphp/mlaphp/blob/c0c90e7217c598c82bb65e5304e8076da381c1f8/src/Mlaphp/Di.php#L130-L137
228,625
mlaphp/mlaphp
src/Mlaphp/Di.php
Di.newInstance
public function newInstance($name) { $name = ltrim($name, '\\'); if (! $this->has($name)) { throw new UnexpectedValueException($name); } return call_user_func($this->callables[$name], $this); }
php
public function newInstance($name) { $name = ltrim($name, '\\'); if (! $this->has($name)) { throw new UnexpectedValueException($name); } return call_user_func($this->callables[$name], $this); }
[ "public", "function", "newInstance", "(", "$", "name", ")", "{", "$", "name", "=", "ltrim", "(", "$", "name", ",", "'\\\\'", ")", ";", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "throw", "new", "UnexpectedValueException", "(", "$", "name", ")", ";", "}", "return", "call_user_func", "(", "$", "this", "->", "callables", "[", "$", "name", "]", ",", "$", "this", ")", ";", "}" ]
Returns a new instance using the named callable. @param string $name The name of the callable to invoke. @return object A new object instance. @throws UnexpectedValueException
[ "Returns", "a", "new", "instance", "using", "the", "named", "callable", "." ]
c0c90e7217c598c82bb65e5304e8076da381c1f8
https://github.com/mlaphp/mlaphp/blob/c0c90e7217c598c82bb65e5304e8076da381c1f8/src/Mlaphp/Di.php#L146-L153
228,626
carpediem/mattermost-webhook
src/Attachment.php
Attachment.fromArray
public static function fromArray(array $arr): self { $prop = $arr + (new self($arr['fallback'] ?? ''))->toArray(); return self::__set_state($prop); }
php
public static function fromArray(array $arr): self { $prop = $arr + (new self($arr['fallback'] ?? ''))->toArray(); return self::__set_state($prop); }
[ "public", "static", "function", "fromArray", "(", "array", "$", "arr", ")", ":", "self", "{", "$", "prop", "=", "$", "arr", "+", "(", "new", "self", "(", "$", "arr", "[", "'fallback'", "]", "??", "''", ")", ")", "->", "toArray", "(", ")", ";", "return", "self", "::", "__set_state", "(", "$", "prop", ")", ";", "}" ]
Returns a new instance from an array. @param array $arr @return self
[ "Returns", "a", "new", "instance", "from", "an", "array", "." ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Attachment.php#L87-L92
228,627
carpediem/mattermost-webhook
src/Attachment.php
Attachment.setFallback
public function setFallback(string $fallback): self { $fallback = trim($fallback); if ('' === $fallback) { throw new Exception('The fallback text can not be empty'); } $this->fallback = $fallback; return $this; }
php
public function setFallback(string $fallback): self { $fallback = trim($fallback); if ('' === $fallback) { throw new Exception('The fallback text can not be empty'); } $this->fallback = $fallback; return $this; }
[ "public", "function", "setFallback", "(", "string", "$", "fallback", ")", ":", "self", "{", "$", "fallback", "=", "trim", "(", "$", "fallback", ")", ";", "if", "(", "''", "===", "$", "fallback", ")", "{", "throw", "new", "Exception", "(", "'The fallback text can not be empty'", ")", ";", "}", "$", "this", "->", "fallback", "=", "$", "fallback", ";", "return", "$", "this", ";", "}" ]
Returns an instance with the specified fallback. A required plain-text summary of the post. This is used in notifications, and in clients that don’t support formatted text (eg IRC). @param string $fallback @throws Exception if the fallback is an empty string @return self
[ "Returns", "an", "instance", "with", "the", "specified", "fallback", "." ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Attachment.php#L248-L258
228,628
carpediem/mattermost-webhook
src/Attachment.php
Attachment.setAuthor
public function setAuthor(string $author_name, $author_link = '', $author_icon = ''): self { $this->author_name = trim($author_name); $this->author_link = filter_uri($author_link, 'author_link'); $this->author_icon = filter_uri($author_icon, 'author_icon'); if ('' === $this->author_name) { $this->author_link = ''; $this->author_icon = ''; } return $this; }
php
public function setAuthor(string $author_name, $author_link = '', $author_icon = ''): self { $this->author_name = trim($author_name); $this->author_link = filter_uri($author_link, 'author_link'); $this->author_icon = filter_uri($author_icon, 'author_icon'); if ('' === $this->author_name) { $this->author_link = ''; $this->author_icon = ''; } return $this; }
[ "public", "function", "setAuthor", "(", "string", "$", "author_name", ",", "$", "author_link", "=", "''", ",", "$", "author_icon", "=", "''", ")", ":", "self", "{", "$", "this", "->", "author_name", "=", "trim", "(", "$", "author_name", ")", ";", "$", "this", "->", "author_link", "=", "filter_uri", "(", "$", "author_link", ",", "'author_link'", ")", ";", "$", "this", "->", "author_icon", "=", "filter_uri", "(", "$", "author_icon", ",", "'author_icon'", ")", ";", "if", "(", "''", "===", "$", "this", "->", "author_name", ")", "{", "$", "this", "->", "author_link", "=", "''", ";", "$", "this", "->", "author_icon", "=", "''", ";", "}", "return", "$", "this", ";", "}" ]
Returns an instance with the specified author. It will be included in a small section at the top of the attachment. @param string $author_name An optional name used to identify the author. @param string|UriInterface $author_link An optional URL used to hyperlink the author_name. If no author_name is specified, this field does nothing. @param string|UriInterface $author_icon An optional URL used to display a 16x16 pixel icon beside the author_name. If no author_name is specified, this field does nothing. @return self
[ "Returns", "an", "instance", "with", "the", "specified", "author", "." ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Attachment.php#L331-L342
228,629
carpediem/mattermost-webhook
src/Attachment.php
Attachment.setAuthorName
public function setAuthorName(string $author_name): self { return $this->setAuthor($author_name, $this->author_link, $this->author_icon); }
php
public function setAuthorName(string $author_name): self { return $this->setAuthor($author_name, $this->author_link, $this->author_icon); }
[ "public", "function", "setAuthorName", "(", "string", "$", "author_name", ")", ":", "self", "{", "return", "$", "this", "->", "setAuthor", "(", "$", "author_name", ",", "$", "this", "->", "author_link", ",", "$", "this", "->", "author_icon", ")", ";", "}" ]
Sets the author name. @param string $author_name DEPRECATION WARNING! This method will be removed in the next major point release @deprecated deprecated since version 2.1.0 @see Attachment::setAuthor @return self
[ "Sets", "the", "author", "name", "." ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Attachment.php#L356-L359
228,630
carpediem/mattermost-webhook
src/Attachment.php
Attachment.setAuthorLink
public function setAuthorLink($author_link): self { return $this->setAuthor($this->author_name, $author_link, $this->author_icon); }
php
public function setAuthorLink($author_link): self { return $this->setAuthor($this->author_name, $author_link, $this->author_icon); }
[ "public", "function", "setAuthorLink", "(", "$", "author_link", ")", ":", "self", "{", "return", "$", "this", "->", "setAuthor", "(", "$", "this", "->", "author_name", ",", "$", "author_link", ",", "$", "this", "->", "author_icon", ")", ";", "}" ]
Sets the author link URI. @param string|UriInterface $author_link DEPRECATION WARNING! This method will be removed in the next major point release @deprecated deprecated since version 2.1.0 @see Attachment::setAuthor @return self
[ "Sets", "the", "author", "link", "URI", "." ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Attachment.php#L373-L376
228,631
carpediem/mattermost-webhook
src/Attachment.php
Attachment.setAuthorIcon
public function setAuthorIcon($author_icon): self { return $this->setAuthor($this->author_name, $this->author_link, $author_icon); }
php
public function setAuthorIcon($author_icon): self { return $this->setAuthor($this->author_name, $this->author_link, $author_icon); }
[ "public", "function", "setAuthorIcon", "(", "$", "author_icon", ")", ":", "self", "{", "return", "$", "this", "->", "setAuthor", "(", "$", "this", "->", "author_name", ",", "$", "this", "->", "author_link", ",", "$", "author_icon", ")", ";", "}" ]
Sets the author name icon URI. @param string|UriInterface $author_icon DEPRECATION WARNING! This method will be removed in the next major point release @deprecated deprecated since version 2.1.0 @see Attachment::setAuthor @return self
[ "Sets", "the", "author", "name", "icon", "URI", "." ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Attachment.php#L390-L393
228,632
carpediem/mattermost-webhook
src/Attachment.php
Attachment.setTitle
public function setTitle(string $title, $title_link = ''): self { $this->title = trim($title); $this->title_link = filter_uri($title_link, 'title_link'); if ('' === $this->title) { $this->title_link = ''; } return $this; }
php
public function setTitle(string $title, $title_link = ''): self { $this->title = trim($title); $this->title_link = filter_uri($title_link, 'title_link'); if ('' === $this->title) { $this->title_link = ''; } return $this; }
[ "public", "function", "setTitle", "(", "string", "$", "title", ",", "$", "title_link", "=", "''", ")", ":", "self", "{", "$", "this", "->", "title", "=", "trim", "(", "$", "title", ")", ";", "$", "this", "->", "title_link", "=", "filter_uri", "(", "$", "title_link", ",", "'title_link'", ")", ";", "if", "(", "''", "===", "$", "this", "->", "title", ")", "{", "$", "this", "->", "title_link", "=", "''", ";", "}", "return", "$", "this", ";", "}" ]
Returns an instance with the specified title. @param string $title An optional title displayed below the author information in the attachment. @param string|UriInterface $title_link An optional URL used to hyperlink the title. If no title is specified, this field does nothing. @return self
[ "Returns", "an", "instance", "with", "the", "specified", "title", "." ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Attachment.php#L405-L414
228,633
carpediem/mattermost-webhook
src/Attachment.php
Attachment.setFields
public function setFields($fields): self { if (!is_iterable($fields)) { throw new Exception(sprintf('%s() expects argument passed to be iterable, %s given', __METHOD__, gettype($fields))); } $this->fields = []; foreach ($fields as $field) { $this->addField(...$field); } return $this; }
php
public function setFields($fields): self { if (!is_iterable($fields)) { throw new Exception(sprintf('%s() expects argument passed to be iterable, %s given', __METHOD__, gettype($fields))); } $this->fields = []; foreach ($fields as $field) { $this->addField(...$field); } return $this; }
[ "public", "function", "setFields", "(", "$", "fields", ")", ":", "self", "{", "if", "(", "!", "is_iterable", "(", "$", "fields", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'%s() expects argument passed to be iterable, %s given'", ",", "__METHOD__", ",", "gettype", "(", "$", "fields", ")", ")", ")", ";", "}", "$", "this", "->", "fields", "=", "[", "]", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "this", "->", "addField", "(", "...", "$", "field", ")", ";", "}", "return", "$", "this", ";", "}" ]
Returns an instance with the specified fields. Fields can be included as an optional array within attachments, and are used to display information in a table format inside the attachment. @param array|Traversable $fields @return self
[ "Returns", "an", "instance", "with", "the", "specified", "fields", "." ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Attachment.php#L426-L438
228,634
carpediem/mattermost-webhook
src/Attachment.php
Attachment.addField
public function addField(string $title, string $value, bool $short = true): self { $this->fields[] = ['title' => trim($title), 'value' => trim($value), 'short' => $short]; return $this; }
php
public function addField(string $title, string $value, bool $short = true): self { $this->fields[] = ['title' => trim($title), 'value' => trim($value), 'short' => $short]; return $this; }
[ "public", "function", "addField", "(", "string", "$", "title", ",", "string", "$", "value", ",", "bool", "$", "short", "=", "true", ")", ":", "self", "{", "$", "this", "->", "fields", "[", "]", "=", "[", "'title'", "=>", "trim", "(", "$", "title", ")", ",", "'value'", "=>", "trim", "(", "$", "value", ")", ",", "'short'", "=>", "$", "short", "]", ";", "return", "$", "this", ";", "}" ]
Returns an instance with the added field to the attachment Adds a single field to the object fields collection. @param string $title A title shown in the table above the value. @param string $value The text value of the field. It can be formatted using markdown. @param bool $short to indicate whether the value is short enough to be displayed beside other values - Optional @return self
[ "Returns", "an", "instance", "with", "the", "added", "field", "to", "the", "attachment" ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Attachment.php#L452-L457
228,635
jeremeamia/FunctionParser
src/Tokenizer.php
Tokenizer.findToken
public function findToken($search, $offset = 0) { if ($search === null) { throw new \InvalidArgumentException('A token cannot be searched for with a null value.'); } elseif (!is_int($offset)) { throw new \InvalidArgumentException('On offset must be specified as an integer.'); } if ($offset >= 0) { // Offset is greater than zero. Search from left to right $tokenizer = clone $this; $is_reversed = false; } else { // Offset is negative. Search from right to left $tokenizer = new Tokenizer(array_reverse($this->tokens)); $offset = abs($offset) - 1; $is_reversed = true; } // Seek to the offset and start the search from there $tokenizer->seek($offset); // Loop through the tokens and search for the target token while ($tokenizer->valid()) { $token = $tokenizer->current(); if ($token->code === $search || $token->name === $search || $token->value === $search) { $index = $tokenizer->key(); // Calculate the index as if the tokenizer is not reversed if ($is_reversed) { $index = count($tokenizer) - $index - 1; } return $index; } $tokenizer->next(); } return false; }
php
public function findToken($search, $offset = 0) { if ($search === null) { throw new \InvalidArgumentException('A token cannot be searched for with a null value.'); } elseif (!is_int($offset)) { throw new \InvalidArgumentException('On offset must be specified as an integer.'); } if ($offset >= 0) { // Offset is greater than zero. Search from left to right $tokenizer = clone $this; $is_reversed = false; } else { // Offset is negative. Search from right to left $tokenizer = new Tokenizer(array_reverse($this->tokens)); $offset = abs($offset) - 1; $is_reversed = true; } // Seek to the offset and start the search from there $tokenizer->seek($offset); // Loop through the tokens and search for the target token while ($tokenizer->valid()) { $token = $tokenizer->current(); if ($token->code === $search || $token->name === $search || $token->value === $search) { $index = $tokenizer->key(); // Calculate the index as if the tokenizer is not reversed if ($is_reversed) { $index = count($tokenizer) - $index - 1; } return $index; } $tokenizer->next(); } return false; }
[ "public", "function", "findToken", "(", "$", "search", ",", "$", "offset", "=", "0", ")", "{", "if", "(", "$", "search", "===", "null", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'A token cannot be searched for with a null value.'", ")", ";", "}", "elseif", "(", "!", "is_int", "(", "$", "offset", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'On offset must be specified as an integer.'", ")", ";", "}", "if", "(", "$", "offset", ">=", "0", ")", "{", "// Offset is greater than zero. Search from left to right", "$", "tokenizer", "=", "clone", "$", "this", ";", "$", "is_reversed", "=", "false", ";", "}", "else", "{", "// Offset is negative. Search from right to left", "$", "tokenizer", "=", "new", "Tokenizer", "(", "array_reverse", "(", "$", "this", "->", "tokens", ")", ")", ";", "$", "offset", "=", "abs", "(", "$", "offset", ")", "-", "1", ";", "$", "is_reversed", "=", "true", ";", "}", "// Seek to the offset and start the search from there", "$", "tokenizer", "->", "seek", "(", "$", "offset", ")", ";", "// Loop through the tokens and search for the target token", "while", "(", "$", "tokenizer", "->", "valid", "(", ")", ")", "{", "$", "token", "=", "$", "tokenizer", "->", "current", "(", ")", ";", "if", "(", "$", "token", "->", "code", "===", "$", "search", "||", "$", "token", "->", "name", "===", "$", "search", "||", "$", "token", "->", "value", "===", "$", "search", ")", "{", "$", "index", "=", "$", "tokenizer", "->", "key", "(", ")", ";", "// Calculate the index as if the tokenizer is not reversed", "if", "(", "$", "is_reversed", ")", "{", "$", "index", "=", "count", "(", "$", "tokenizer", ")", "-", "$", "index", "-", "1", ";", "}", "return", "$", "index", ";", "}", "$", "tokenizer", "->", "next", "(", ")", ";", "}", "return", "false", ";", "}" ]
Find a token in the tokenizer. You can search by the token's literal code or name. You can also specify on offset for the search. If the offset is negative, the search will be done starting from the end. @param string|integer $search The token's literal code or name. @param integer $offset The offset to start searching from. A negative offest searches from the end. @return integer|boolean The index of the token that has been found or false.
[ "Find", "a", "token", "in", "the", "tokenizer", ".", "You", "can", "search", "by", "the", "token", "s", "literal", "code", "or", "name", ".", "You", "can", "also", "specify", "on", "offset", "for", "the", "search", ".", "If", "the", "offset", "is", "negative", "the", "search", "will", "be", "done", "starting", "from", "the", "end", "." ]
035b52000b88ea8d72a6647dd4cd39f080cf7ada
https://github.com/jeremeamia/FunctionParser/blob/035b52000b88ea8d72a6647dd4cd39f080cf7ada/src/Tokenizer.php#L114-L164
228,636
jeremeamia/FunctionParser
src/Tokenizer.php
Tokenizer.getTokenRange
public function getTokenRange($start, $finish) { $tokens = array_slice($this->tokens, (integer) $start, (integer) $finish - (integer) $start); return new Tokenizer($tokens); }
php
public function getTokenRange($start, $finish) { $tokens = array_slice($this->tokens, (integer) $start, (integer) $finish - (integer) $start); return new Tokenizer($tokens); }
[ "public", "function", "getTokenRange", "(", "$", "start", ",", "$", "finish", ")", "{", "$", "tokens", "=", "array_slice", "(", "$", "this", "->", "tokens", ",", "(", "integer", ")", "$", "start", ",", "(", "integer", ")", "$", "finish", "-", "(", "integer", ")", "$", "start", ")", ";", "return", "new", "Tokenizer", "(", "$", "tokens", ")", ";", "}" ]
Returns a new tokenizer that consists of a subset of the tokens specified by the provided range. @param integer $start The starting offset of the range @param integer $finish The ending offset of the range @return \FunctionParser\Tokenizer A tokenizer with a subset of tokens
[ "Returns", "a", "new", "tokenizer", "that", "consists", "of", "a", "subset", "of", "the", "tokens", "specified", "by", "the", "provided", "range", "." ]
035b52000b88ea8d72a6647dd4cd39f080cf7ada
https://github.com/jeremeamia/FunctionParser/blob/035b52000b88ea8d72a6647dd4cd39f080cf7ada/src/Tokenizer.php#L184-L189
228,637
jeremeamia/FunctionParser
src/Tokenizer.php
Tokenizer.prependTokens
public function prependTokens(Tokenizer $new_tokens) { $this->tokens = array_merge($new_tokens->asArray(), $this->tokens); $this->rewind(); return $this; }
php
public function prependTokens(Tokenizer $new_tokens) { $this->tokens = array_merge($new_tokens->asArray(), $this->tokens); $this->rewind(); return $this; }
[ "public", "function", "prependTokens", "(", "Tokenizer", "$", "new_tokens", ")", "{", "$", "this", "->", "tokens", "=", "array_merge", "(", "$", "new_tokens", "->", "asArray", "(", ")", ",", "$", "this", "->", "tokens", ")", ";", "$", "this", "->", "rewind", "(", ")", ";", "return", "$", "this", ";", "}" ]
Prepends a tokenizer to the beginning of this tokenizer. @param \FunctionParser\Tokenizer $new_tokens The tokenizer to prepend. @return \FunctionParser\Tokenizer
[ "Prepends", "a", "tokenizer", "to", "the", "beginning", "of", "this", "tokenizer", "." ]
035b52000b88ea8d72a6647dd4cd39f080cf7ada
https://github.com/jeremeamia/FunctionParser/blob/035b52000b88ea8d72a6647dd4cd39f080cf7ada/src/Tokenizer.php#L197-L203
228,638
jeremeamia/FunctionParser
src/Tokenizer.php
Tokenizer.appendTokens
public function appendTokens(Tokenizer $new_tokens) { $this->tokens = array_merge($this->tokens, $new_tokens->asArray()); $this->rewind(); return $this; }
php
public function appendTokens(Tokenizer $new_tokens) { $this->tokens = array_merge($this->tokens, $new_tokens->asArray()); $this->rewind(); return $this; }
[ "public", "function", "appendTokens", "(", "Tokenizer", "$", "new_tokens", ")", "{", "$", "this", "->", "tokens", "=", "array_merge", "(", "$", "this", "->", "tokens", ",", "$", "new_tokens", "->", "asArray", "(", ")", ")", ";", "$", "this", "->", "rewind", "(", ")", ";", "return", "$", "this", ";", "}" ]
Appends a tokenizer to the beginning of this tokenizer. @param \FunctionParser\Tokenizer $new_tokens The tokenizer to append. @return \FunctionParser\Tokenizer
[ "Appends", "a", "tokenizer", "to", "the", "beginning", "of", "this", "tokenizer", "." ]
035b52000b88ea8d72a6647dd4cd39f080cf7ada
https://github.com/jeremeamia/FunctionParser/blob/035b52000b88ea8d72a6647dd4cd39f080cf7ada/src/Tokenizer.php#L211-L217
228,639
jeremeamia/FunctionParser
src/Tokenizer.php
Tokenizer.offsetSet
public function offsetSet($offset, $value) { if (!(is_integer($offset) && $offset >= 0 && $offset <= $this->count())) { throw new \InvalidArgumentException('The offset must be a valid, positive integer.'); } if (!$value instanceof Token) { throw new \InvalidArgumentException('The value provided must be a token.'); } $this->tokens[$offset] = $value; }
php
public function offsetSet($offset, $value) { if (!(is_integer($offset) && $offset >= 0 && $offset <= $this->count())) { throw new \InvalidArgumentException('The offset must be a valid, positive integer.'); } if (!$value instanceof Token) { throw new \InvalidArgumentException('The value provided must be a token.'); } $this->tokens[$offset] = $value; }
[ "public", "function", "offsetSet", "(", "$", "offset", ",", "$", "value", ")", "{", "if", "(", "!", "(", "is_integer", "(", "$", "offset", ")", "&&", "$", "offset", ">=", "0", "&&", "$", "offset", "<=", "$", "this", "->", "count", "(", ")", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The offset must be a valid, positive integer.'", ")", ";", "}", "if", "(", "!", "$", "value", "instanceof", "Token", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The value provided must be a token.'", ")", ";", "}", "$", "this", "->", "tokens", "[", "$", "offset", "]", "=", "$", "value", ";", "}" ]
Sets the token at the specified offset. @param integer $offset The offset to set. @param \FunctionParser\Token The token to set. @throws \InvalidArgumentException
[ "Sets", "the", "token", "at", "the", "specified", "offset", "." ]
035b52000b88ea8d72a6647dd4cd39f080cf7ada
https://github.com/jeremeamia/FunctionParser/blob/035b52000b88ea8d72a6647dd4cd39f080cf7ada/src/Tokenizer.php#L336-L349
228,640
jeremeamia/FunctionParser
src/Tokenizer.php
Tokenizer.offsetUnset
public function offsetUnset($offset) { if ($this->offsetExists($offset)) { unset($this->tokens[$offset]); // Re-index the tokens $this->tokens = array_values($this->tokens); // If the current index is now outside of the valid indeces, reset the index if (!$this->valid()) { $this->rewind(); } } }
php
public function offsetUnset($offset) { if ($this->offsetExists($offset)) { unset($this->tokens[$offset]); // Re-index the tokens $this->tokens = array_values($this->tokens); // If the current index is now outside of the valid indeces, reset the index if (!$this->valid()) { $this->rewind(); } } }
[ "public", "function", "offsetUnset", "(", "$", "offset", ")", "{", "if", "(", "$", "this", "->", "offsetExists", "(", "$", "offset", ")", ")", "{", "unset", "(", "$", "this", "->", "tokens", "[", "$", "offset", "]", ")", ";", "// Re-index the tokens", "$", "this", "->", "tokens", "=", "array_values", "(", "$", "this", "->", "tokens", ")", ";", "// If the current index is now outside of the valid indeces, reset the index", "if", "(", "!", "$", "this", "->", "valid", "(", ")", ")", "{", "$", "this", "->", "rewind", "(", ")", ";", "}", "}", "}" ]
Unsets the token at the specified offset. @param integer $offset The offset to unset.
[ "Unsets", "the", "token", "at", "the", "specified", "offset", "." ]
035b52000b88ea8d72a6647dd4cd39f080cf7ada
https://github.com/jeremeamia/FunctionParser/blob/035b52000b88ea8d72a6647dd4cd39f080cf7ada/src/Tokenizer.php#L356-L371
228,641
jeremeamia/FunctionParser
src/Tokenizer.php
Tokenizer.unserialize
public function unserialize($serialized) { $unserialized = unserialize($serialized); $this->__construct($unserialized['tokens']); $this->seek($unserialized['index']); }
php
public function unserialize($serialized) { $unserialized = unserialize($serialized); $this->__construct($unserialized['tokens']); $this->seek($unserialized['index']); }
[ "public", "function", "unserialize", "(", "$", "serialized", ")", "{", "$", "unserialized", "=", "unserialize", "(", "$", "serialized", ")", ";", "$", "this", "->", "__construct", "(", "$", "unserialized", "[", "'tokens'", "]", ")", ";", "$", "this", "->", "seek", "(", "$", "unserialized", "[", "'index'", "]", ")", ";", "}" ]
Unserialize the tokenizer. @param string $serialized The serialized tokenizer.
[ "Unserialize", "the", "tokenizer", "." ]
035b52000b88ea8d72a6647dd4cd39f080cf7ada
https://github.com/jeremeamia/FunctionParser/blob/035b52000b88ea8d72a6647dd4cd39f080cf7ada/src/Tokenizer.php#L401-L406
228,642
arogozin/tagcloud
src/Arg/Tagcloud/Tagcloud.php
Tagcloud.htmlizeTag
public function htmlizeTag($arrayInfo, $sizeRange) { if ( isset($this->_htmlizeTagFunction) ) { // this cannot be writen in one line or the PHP interpreter will puke // appearantly, it's okay to have a function in a variable, // but it's not okay to have it in an instance-varriable. $htmlizer = $this->_htmlizeTagFunction; return $htmlizer($arrayInfo, $sizeRange); } else { return "<span class='tag size{$sizeRange}'> &nbsp; {$arrayInfo['tag']} &nbsp; </span>"; } }
php
public function htmlizeTag($arrayInfo, $sizeRange) { if ( isset($this->_htmlizeTagFunction) ) { // this cannot be writen in one line or the PHP interpreter will puke // appearantly, it's okay to have a function in a variable, // but it's not okay to have it in an instance-varriable. $htmlizer = $this->_htmlizeTagFunction; return $htmlizer($arrayInfo, $sizeRange); } else { return "<span class='tag size{$sizeRange}'> &nbsp; {$arrayInfo['tag']} &nbsp; </span>"; } }
[ "public", "function", "htmlizeTag", "(", "$", "arrayInfo", ",", "$", "sizeRange", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_htmlizeTagFunction", ")", ")", "{", "// this cannot be writen in one line or the PHP interpreter will puke", "// appearantly, it's okay to have a function in a variable,", "// but it's not okay to have it in an instance-varriable.", "$", "htmlizer", "=", "$", "this", "->", "_htmlizeTagFunction", ";", "return", "$", "htmlizer", "(", "$", "arrayInfo", ",", "$", "sizeRange", ")", ";", "}", "else", "{", "return", "\"<span class='tag size{$sizeRange}'> &nbsp; {$arrayInfo['tag']} &nbsp; </span>\"", ";", "}", "}" ]
Convert a tag into an html-snippet This function is mainly an anchor to decide if a user-supplied custom function should be used or the normal output method. This will most likely only work in PHP >= 5.3 @param array $arrayInfo @param string $sizeRange @return string
[ "Convert", "a", "tag", "into", "an", "html", "-", "snippet" ]
aa5bf828ee5f5be28d4cd3ee1a19c75dcf924a83
https://github.com/arogozin/tagcloud/blob/aa5bf828ee5f5be28d4cd3ee1a19c75dcf924a83/src/Arg/Tagcloud/Tagcloud.php#L362-L373
228,643
contributte/social
src/Google/PlusOne/PlusOne.php
PlusOne.render
public function render(?string $url = null): void { // Get HTML element $el = $this->getElementPrototype(); $el->size = $this->size; $el->annotation = $this->annotation; // Set given URL or filled url if ($url !== null) { Validators::assert($url, 'string|url'); $el->href = $url; } else { $el->href = $this->url; } // Set width in INLINE mode if ($this->annotation === self::ANNOTATION_INLINE) { $el->width = $this->width; } // Set callback, if filled if ($this->callback !== null) { $el->callback = $this->callback; } // Set properties as data attributes foreach ($this->getProperties() as $key => $value) { if ($value !== null && !empty($value)) { $el->{'data-' . $key} = $value; } } echo $el; }
php
public function render(?string $url = null): void { // Get HTML element $el = $this->getElementPrototype(); $el->size = $this->size; $el->annotation = $this->annotation; // Set given URL or filled url if ($url !== null) { Validators::assert($url, 'string|url'); $el->href = $url; } else { $el->href = $this->url; } // Set width in INLINE mode if ($this->annotation === self::ANNOTATION_INLINE) { $el->width = $this->width; } // Set callback, if filled if ($this->callback !== null) { $el->callback = $this->callback; } // Set properties as data attributes foreach ($this->getProperties() as $key => $value) { if ($value !== null && !empty($value)) { $el->{'data-' . $key} = $value; } } echo $el; }
[ "public", "function", "render", "(", "?", "string", "$", "url", "=", "null", ")", ":", "void", "{", "// Get HTML element", "$", "el", "=", "$", "this", "->", "getElementPrototype", "(", ")", ";", "$", "el", "->", "size", "=", "$", "this", "->", "size", ";", "$", "el", "->", "annotation", "=", "$", "this", "->", "annotation", ";", "// Set given URL or filled url", "if", "(", "$", "url", "!==", "null", ")", "{", "Validators", "::", "assert", "(", "$", "url", ",", "'string|url'", ")", ";", "$", "el", "->", "href", "=", "$", "url", ";", "}", "else", "{", "$", "el", "->", "href", "=", "$", "this", "->", "url", ";", "}", "// Set width in INLINE mode", "if", "(", "$", "this", "->", "annotation", "===", "self", "::", "ANNOTATION_INLINE", ")", "{", "$", "el", "->", "width", "=", "$", "this", "->", "width", ";", "}", "// Set callback, if filled", "if", "(", "$", "this", "->", "callback", "!==", "null", ")", "{", "$", "el", "->", "callback", "=", "$", "this", "->", "callback", ";", "}", "// Set properties as data attributes", "foreach", "(", "$", "this", "->", "getProperties", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "!==", "null", "&&", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "el", "->", "{", "'data-'", ".", "$", "key", "}", "=", "$", "value", ";", "}", "}", "echo", "$", "el", ";", "}" ]
Render google +1 button
[ "Render", "google", "+", "1", "button" ]
c045978c6fe5fc179eaacb20cacc25d4c46b9153
https://github.com/contributte/social/blob/c045978c6fe5fc179eaacb20cacc25d4c46b9153/src/Google/PlusOne/PlusOne.php#L201-L234
228,644
contributte/social
src/Google/PlusOne/PlusOne.php
PlusOne.renderJs
public function renderJs(): void { if ($this->mode === self::MODE_DEFAULT) { $el = Html::el('script type="text/javascript" async defer'); $el->src = self::GOOGLE_PLATFORM_URL; $el->addText("{lang: '" . $this->lang . "'}"); echo $el; } elseif ($this->mode === self::MODE_EXPLICIT) { $wrapper = Html::el(); $el = Html::el('script type="text/javascript" async defer'); $el->src = self::GOOGLE_PLATFORM_URL; $el->addText("{lang: '" . $this->lang . "', parsetags: 'explicit'}"); $wrapper->addHtml($el); $el = Html::el('script type="text/javascript"'); $el->addText('gapi.plusone.go();'); $wrapper->addHtml($el); echo $wrapper; } elseif ($this->mode === self::MODE_DYNAMIC) { $el = Html::el('script type="text/javascript"'); $el->addText("window.___gcfg = {lang: '" . $this->lang . "'};"); $el->addText("(function(){var po=document.createElement('script');po.type='text/javascript';po.async=true;po.src='" . self::GOOGLE_PLATFORM_URL . "';vars=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(po, s);})();"); echo $el; } }
php
public function renderJs(): void { if ($this->mode === self::MODE_DEFAULT) { $el = Html::el('script type="text/javascript" async defer'); $el->src = self::GOOGLE_PLATFORM_URL; $el->addText("{lang: '" . $this->lang . "'}"); echo $el; } elseif ($this->mode === self::MODE_EXPLICIT) { $wrapper = Html::el(); $el = Html::el('script type="text/javascript" async defer'); $el->src = self::GOOGLE_PLATFORM_URL; $el->addText("{lang: '" . $this->lang . "', parsetags: 'explicit'}"); $wrapper->addHtml($el); $el = Html::el('script type="text/javascript"'); $el->addText('gapi.plusone.go();'); $wrapper->addHtml($el); echo $wrapper; } elseif ($this->mode === self::MODE_DYNAMIC) { $el = Html::el('script type="text/javascript"'); $el->addText("window.___gcfg = {lang: '" . $this->lang . "'};"); $el->addText("(function(){var po=document.createElement('script');po.type='text/javascript';po.async=true;po.src='" . self::GOOGLE_PLATFORM_URL . "';vars=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(po, s);})();"); echo $el; } }
[ "public", "function", "renderJs", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "mode", "===", "self", "::", "MODE_DEFAULT", ")", "{", "$", "el", "=", "Html", "::", "el", "(", "'script type=\"text/javascript\" async defer'", ")", ";", "$", "el", "->", "src", "=", "self", "::", "GOOGLE_PLATFORM_URL", ";", "$", "el", "->", "addText", "(", "\"{lang: '\"", ".", "$", "this", "->", "lang", ".", "\"'}\"", ")", ";", "echo", "$", "el", ";", "}", "elseif", "(", "$", "this", "->", "mode", "===", "self", "::", "MODE_EXPLICIT", ")", "{", "$", "wrapper", "=", "Html", "::", "el", "(", ")", ";", "$", "el", "=", "Html", "::", "el", "(", "'script type=\"text/javascript\" async defer'", ")", ";", "$", "el", "->", "src", "=", "self", "::", "GOOGLE_PLATFORM_URL", ";", "$", "el", "->", "addText", "(", "\"{lang: '\"", ".", "$", "this", "->", "lang", ".", "\"', parsetags: 'explicit'}\"", ")", ";", "$", "wrapper", "->", "addHtml", "(", "$", "el", ")", ";", "$", "el", "=", "Html", "::", "el", "(", "'script type=\"text/javascript\"'", ")", ";", "$", "el", "->", "addText", "(", "'gapi.plusone.go();'", ")", ";", "$", "wrapper", "->", "addHtml", "(", "$", "el", ")", ";", "echo", "$", "wrapper", ";", "}", "elseif", "(", "$", "this", "->", "mode", "===", "self", "::", "MODE_DYNAMIC", ")", "{", "$", "el", "=", "Html", "::", "el", "(", "'script type=\"text/javascript\"'", ")", ";", "$", "el", "->", "addText", "(", "\"window.___gcfg = {lang: '\"", ".", "$", "this", "->", "lang", ".", "\"'};\"", ")", ";", "$", "el", "->", "addText", "(", "\"(function(){var po=document.createElement('script');po.type='text/javascript';po.async=true;po.src='\"", ".", "self", "::", "GOOGLE_PLATFORM_URL", ".", "\"';vars=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(po, s);})();\"", ")", ";", "echo", "$", "el", ";", "}", "}" ]
Render google javascript
[ "Render", "google", "javascript" ]
c045978c6fe5fc179eaacb20cacc25d4c46b9153
https://github.com/contributte/social/blob/c045978c6fe5fc179eaacb20cacc25d4c46b9153/src/Google/PlusOne/PlusOne.php#L239-L269
228,645
contributte/social
src/Twitter/TweetButton/TweetButton.php
TweetButton.setShareButton
public function setShareButton($text = null): void { $this->element->addClass('twitter-share-button'); $this->href = self::TWITTER_SHARE_URL; if ($text) { $this->elementText = 'Tweet ' . $text; } }
php
public function setShareButton($text = null): void { $this->element->addClass('twitter-share-button'); $this->href = self::TWITTER_SHARE_URL; if ($text) { $this->elementText = 'Tweet ' . $text; } }
[ "public", "function", "setShareButton", "(", "$", "text", "=", "null", ")", ":", "void", "{", "$", "this", "->", "element", "->", "addClass", "(", "'twitter-share-button'", ")", ";", "$", "this", "->", "href", "=", "self", "::", "TWITTER_SHARE_URL", ";", "if", "(", "$", "text", ")", "{", "$", "this", "->", "elementText", "=", "'Tweet '", ".", "$", "text", ";", "}", "}" ]
Configure share button @param string $text [optional]
[ "Configure", "share", "button" ]
c045978c6fe5fc179eaacb20cacc25d4c46b9153
https://github.com/contributte/social/blob/c045978c6fe5fc179eaacb20cacc25d4c46b9153/src/Twitter/TweetButton/TweetButton.php#L370-L378
228,646
contributte/social
src/Twitter/TweetButton/TweetButton.php
TweetButton.setMentionButton
public function setMentionButton($mention = null): void { $this->element->addClass('twitter-mention-button'); // Build URL $url = new Url(self::TWITTER_TWEET_URL); $url->setQueryParameter('screen_name', $mention); $this->href = (string) $url; if ($mention) { $this->elementText = 'Tweet to @' . $mention; } }
php
public function setMentionButton($mention = null): void { $this->element->addClass('twitter-mention-button'); // Build URL $url = new Url(self::TWITTER_TWEET_URL); $url->setQueryParameter('screen_name', $mention); $this->href = (string) $url; if ($mention) { $this->elementText = 'Tweet to @' . $mention; } }
[ "public", "function", "setMentionButton", "(", "$", "mention", "=", "null", ")", ":", "void", "{", "$", "this", "->", "element", "->", "addClass", "(", "'twitter-mention-button'", ")", ";", "// Build URL", "$", "url", "=", "new", "Url", "(", "self", "::", "TWITTER_TWEET_URL", ")", ";", "$", "url", "->", "setQueryParameter", "(", "'screen_name'", ",", "$", "mention", ")", ";", "$", "this", "->", "href", "=", "(", "string", ")", "$", "url", ";", "if", "(", "$", "mention", ")", "{", "$", "this", "->", "elementText", "=", "'Tweet to @'", ".", "$", "mention", ";", "}", "}" ]
Configure mention button @param string $mention
[ "Configure", "mention", "button" ]
c045978c6fe5fc179eaacb20cacc25d4c46b9153
https://github.com/contributte/social/blob/c045978c6fe5fc179eaacb20cacc25d4c46b9153/src/Twitter/TweetButton/TweetButton.php#L385-L397
228,647
contributte/social
src/Twitter/TweetButton/TweetButton.php
TweetButton.setHashtagButton
public function setHashtagButton($hashtag = null): void { $this->element->addClass('twitter-hashtag-button'); // Build URL $url = new Url(self::TWITTER_TWEET_URL); $url->setQueryParameter('button_hashtag', $hashtag); $this->href = (string) $url; if ($hashtag) { $this->elementText = 'Tweet #' . $hashtag; } }
php
public function setHashtagButton($hashtag = null): void { $this->element->addClass('twitter-hashtag-button'); // Build URL $url = new Url(self::TWITTER_TWEET_URL); $url->setQueryParameter('button_hashtag', $hashtag); $this->href = (string) $url; if ($hashtag) { $this->elementText = 'Tweet #' . $hashtag; } }
[ "public", "function", "setHashtagButton", "(", "$", "hashtag", "=", "null", ")", ":", "void", "{", "$", "this", "->", "element", "->", "addClass", "(", "'twitter-hashtag-button'", ")", ";", "// Build URL", "$", "url", "=", "new", "Url", "(", "self", "::", "TWITTER_TWEET_URL", ")", ";", "$", "url", "->", "setQueryParameter", "(", "'button_hashtag'", ",", "$", "hashtag", ")", ";", "$", "this", "->", "href", "=", "(", "string", ")", "$", "url", ";", "if", "(", "$", "hashtag", ")", "{", "$", "this", "->", "elementText", "=", "'Tweet #'", ".", "$", "hashtag", ";", "}", "}" ]
Configure hashtag button @param string $hashtag
[ "Configure", "hashtag", "button" ]
c045978c6fe5fc179eaacb20cacc25d4c46b9153
https://github.com/contributte/social/blob/c045978c6fe5fc179eaacb20cacc25d4c46b9153/src/Twitter/TweetButton/TweetButton.php#L404-L416
228,648
contributte/social
src/Twitter/TweetButton/TweetButton.php
TweetButton.render
public function render(?string $url = null): void { // Get HTML element $el = $this->getElementPrototype(); $el->addText($this->getElementText()); $el->href($this->getHref()); // Set URL if ($url !== null) { Validators::assert($url, 'string|url'); $el->{'data-url'} = $url; } elseif ($this->url !== null) { $el->{'data-url'} = $this->url; } // List of default properties $properties = [ 'via' => $this->via, 'text' => $this->text, 'related' => $this->related, 'count' => $this->count, 'lang' => $this->lang, 'counturl' => $this->counturl, 'hashtags' => $this->hashtags, 'size' => $this->size, 'dnt' => $this->dnt, ]; // Merge with custom properties $properties = array_merge($properties, $this->getProperties()); // Set properties as data attributes foreach ($properties as $key => $value) { if ($value !== null && !empty($value)) { $el->{'data-' . $key} = $value; } } echo $el; }
php
public function render(?string $url = null): void { // Get HTML element $el = $this->getElementPrototype(); $el->addText($this->getElementText()); $el->href($this->getHref()); // Set URL if ($url !== null) { Validators::assert($url, 'string|url'); $el->{'data-url'} = $url; } elseif ($this->url !== null) { $el->{'data-url'} = $this->url; } // List of default properties $properties = [ 'via' => $this->via, 'text' => $this->text, 'related' => $this->related, 'count' => $this->count, 'lang' => $this->lang, 'counturl' => $this->counturl, 'hashtags' => $this->hashtags, 'size' => $this->size, 'dnt' => $this->dnt, ]; // Merge with custom properties $properties = array_merge($properties, $this->getProperties()); // Set properties as data attributes foreach ($properties as $key => $value) { if ($value !== null && !empty($value)) { $el->{'data-' . $key} = $value; } } echo $el; }
[ "public", "function", "render", "(", "?", "string", "$", "url", "=", "null", ")", ":", "void", "{", "// Get HTML element", "$", "el", "=", "$", "this", "->", "getElementPrototype", "(", ")", ";", "$", "el", "->", "addText", "(", "$", "this", "->", "getElementText", "(", ")", ")", ";", "$", "el", "->", "href", "(", "$", "this", "->", "getHref", "(", ")", ")", ";", "// Set URL", "if", "(", "$", "url", "!==", "null", ")", "{", "Validators", "::", "assert", "(", "$", "url", ",", "'string|url'", ")", ";", "$", "el", "->", "{", "'data-url'", "}", "=", "$", "url", ";", "}", "elseif", "(", "$", "this", "->", "url", "!==", "null", ")", "{", "$", "el", "->", "{", "'data-url'", "}", "=", "$", "this", "->", "url", ";", "}", "// List of default properties", "$", "properties", "=", "[", "'via'", "=>", "$", "this", "->", "via", ",", "'text'", "=>", "$", "this", "->", "text", ",", "'related'", "=>", "$", "this", "->", "related", ",", "'count'", "=>", "$", "this", "->", "count", ",", "'lang'", "=>", "$", "this", "->", "lang", ",", "'counturl'", "=>", "$", "this", "->", "counturl", ",", "'hashtags'", "=>", "$", "this", "->", "hashtags", ",", "'size'", "=>", "$", "this", "->", "size", ",", "'dnt'", "=>", "$", "this", "->", "dnt", ",", "]", ";", "// Merge with custom properties", "$", "properties", "=", "array_merge", "(", "$", "properties", ",", "$", "this", "->", "getProperties", "(", ")", ")", ";", "// Set properties as data attributes", "foreach", "(", "$", "properties", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "!==", "null", "&&", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "el", "->", "{", "'data-'", ".", "$", "key", "}", "=", "$", "value", ";", "}", "}", "echo", "$", "el", ";", "}" ]
Render twitter tweet button
[ "Render", "twitter", "tweet", "button" ]
c045978c6fe5fc179eaacb20cacc25d4c46b9153
https://github.com/contributte/social/blob/c045978c6fe5fc179eaacb20cacc25d4c46b9153/src/Twitter/TweetButton/TweetButton.php#L423-L462
228,649
contributte/social
src/Twitter/TweetButton/TweetButton.php
TweetButton.renderJs
public function renderJs(): void { $el = Html::el('script type="text/javascript"'); $el->addText('window.twttr=(function(d,s,id){var t,js,fjs=d.getElementsByTagName(s)[0];if(d.getElementById(id)){return}js=d.createElement(s);js.id=id;js.src="' . self::TWITTER_PLATFORM_URL . '";fjs.parentNode.insertBefore(js,fjs);return window.twttr||(t={_e:[],ready:function(f){t._e.push(f)}})}(document,"script","twitter-wjs"));'); echo $el; }
php
public function renderJs(): void { $el = Html::el('script type="text/javascript"'); $el->addText('window.twttr=(function(d,s,id){var t,js,fjs=d.getElementsByTagName(s)[0];if(d.getElementById(id)){return}js=d.createElement(s);js.id=id;js.src="' . self::TWITTER_PLATFORM_URL . '";fjs.parentNode.insertBefore(js,fjs);return window.twttr||(t={_e:[],ready:function(f){t._e.push(f)}})}(document,"script","twitter-wjs"));'); echo $el; }
[ "public", "function", "renderJs", "(", ")", ":", "void", "{", "$", "el", "=", "Html", "::", "el", "(", "'script type=\"text/javascript\"'", ")", ";", "$", "el", "->", "addText", "(", "'window.twttr=(function(d,s,id){var t,js,fjs=d.getElementsByTagName(s)[0];if(d.getElementById(id)){return}js=d.createElement(s);js.id=id;js.src=\"'", ".", "self", "::", "TWITTER_PLATFORM_URL", ".", "'\";fjs.parentNode.insertBefore(js,fjs);return window.twttr||(t={_e:[],ready:function(f){t._e.push(f)}})}(document,\"script\",\"twitter-wjs\"));'", ")", ";", "echo", "$", "el", ";", "}" ]
Render twitter javascript
[ "Render", "twitter", "javascript" ]
c045978c6fe5fc179eaacb20cacc25d4c46b9153
https://github.com/contributte/social/blob/c045978c6fe5fc179eaacb20cacc25d4c46b9153/src/Twitter/TweetButton/TweetButton.php#L467-L473
228,650
mariano/disque-php
src/Client.php
Client.setConnectionManager
public function setConnectionManager(ManagerInterface $manager) { $this->connectionManager = $manager; foreach ($this->servers as $server) { $this->connectionManager->addServer($server); } }
php
public function setConnectionManager(ManagerInterface $manager) { $this->connectionManager = $manager; foreach ($this->servers as $server) { $this->connectionManager->addServer($server); } }
[ "public", "function", "setConnectionManager", "(", "ManagerInterface", "$", "manager", ")", "{", "$", "this", "->", "connectionManager", "=", "$", "manager", ";", "foreach", "(", "$", "this", "->", "servers", "as", "$", "server", ")", "{", "$", "this", "->", "connectionManager", "->", "addServer", "(", "$", "server", ")", ";", "}", "}" ]
Set a connection manager @param ManagerInterface $manager
[ "Set", "a", "connection", "manager" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Client.php#L100-L106
228,651
mariano/disque-php
src/Client.php
Client.registerCommand
public function registerCommand(CommandInterface $commandHandler) { $command = strtoupper($commandHandler->getCommand()); $this->commandHandlers[$command] = $commandHandler; }
php
public function registerCommand(CommandInterface $commandHandler) { $command = strtoupper($commandHandler->getCommand()); $this->commandHandlers[$command] = $commandHandler; }
[ "public", "function", "registerCommand", "(", "CommandInterface", "$", "commandHandler", ")", "{", "$", "command", "=", "strtoupper", "(", "$", "commandHandler", "->", "getCommand", "(", ")", ")", ";", "$", "this", "->", "commandHandlers", "[", "$", "command", "]", "=", "$", "commandHandler", ";", "}" ]
Register a command handler @param CommandInterface $commandHandler Command @return void
[ "Register", "a", "command", "handler" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Client.php#L161-L165
228,652
mariano/disque-php
src/Client.php
Client.queue
public function queue($name) { if (!isset($this->queues[$name])) { $this->queues[$name] = new Queue($this, $name); } return $this->queues[$name]; }
php
public function queue($name) { if (!isset($this->queues[$name])) { $this->queues[$name] = new Queue($this, $name); } return $this->queues[$name]; }
[ "public", "function", "queue", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "queues", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "queues", "[", "$", "name", "]", "=", "new", "Queue", "(", "$", "this", ",", "$", "name", ")", ";", "}", "return", "$", "this", "->", "queues", "[", "$", "name", "]", ";", "}" ]
Get a queue @param string $name Queue name @return Queue Queue
[ "Get", "a", "queue" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Client.php#L173-L179
228,653
mariano/disque-php
src/Queue/Queue.php
Queue.schedule
public function schedule(JobInterface $job, DateTime $when, array $options = []) { if (!isset($this->timeZone)) { $this->timeZone = new DateTimeZone(self::DEFAULT_JOB_TIMEZONE); } $date = clone($when); $date->setTimeZone($this->timeZone); $now = new DateTime('now', $this->timeZone); if ($date < $now) { throw new InvalidArgumentException('Specified schedule time has passed'); } $options['delay'] = ($date->getTimestamp() - $now->getTimestamp()); return $this->push($job, $options); }
php
public function schedule(JobInterface $job, DateTime $when, array $options = []) { if (!isset($this->timeZone)) { $this->timeZone = new DateTimeZone(self::DEFAULT_JOB_TIMEZONE); } $date = clone($when); $date->setTimeZone($this->timeZone); $now = new DateTime('now', $this->timeZone); if ($date < $now) { throw new InvalidArgumentException('Specified schedule time has passed'); } $options['delay'] = ($date->getTimestamp() - $now->getTimestamp()); return $this->push($job, $options); }
[ "public", "function", "schedule", "(", "JobInterface", "$", "job", ",", "DateTime", "$", "when", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "timeZone", ")", ")", "{", "$", "this", "->", "timeZone", "=", "new", "DateTimeZone", "(", "self", "::", "DEFAULT_JOB_TIMEZONE", ")", ";", "}", "$", "date", "=", "clone", "(", "$", "when", ")", ";", "$", "date", "->", "setTimeZone", "(", "$", "this", "->", "timeZone", ")", ";", "$", "now", "=", "new", "DateTime", "(", "'now'", ",", "$", "this", "->", "timeZone", ")", ";", "if", "(", "$", "date", "<", "$", "now", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Specified schedule time has passed'", ")", ";", "}", "$", "options", "[", "'delay'", "]", "=", "(", "$", "date", "->", "getTimestamp", "(", ")", "-", "$", "now", "->", "getTimestamp", "(", ")", ")", ";", "return", "$", "this", "->", "push", "(", "$", "job", ",", "$", "options", ")", ";", "}" ]
Pushes a job into the queue, setting it to be up for processing only at the specific date & time. @param JobInterface $job Job @param DateTime $when Date & time on when job should be ready for processing @param array $options ADDJOB options sent to the client @return JobInterface Job pushed @throws InvalidArgumentException
[ "Pushes", "a", "job", "into", "the", "queue", "setting", "it", "to", "be", "up", "for", "processing", "only", "at", "the", "specific", "date", "&", "time", "." ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Queue/Queue.php#L89-L104
228,654
mariano/disque-php
src/Queue/Queue.php
Queue.push
public function push(JobInterface $job, array $options = []) { $this->checkConnected(); $id = $this->client->addJob($this->name, $this->marshaler->marshal($job), $options); $job->setId($id); return $job; }
php
public function push(JobInterface $job, array $options = []) { $this->checkConnected(); $id = $this->client->addJob($this->name, $this->marshaler->marshal($job), $options); $job->setId($id); return $job; }
[ "public", "function", "push", "(", "JobInterface", "$", "job", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "checkConnected", "(", ")", ";", "$", "id", "=", "$", "this", "->", "client", "->", "addJob", "(", "$", "this", "->", "name", ",", "$", "this", "->", "marshaler", "->", "marshal", "(", "$", "job", ")", ",", "$", "options", ")", ";", "$", "job", "->", "setId", "(", "$", "id", ")", ";", "return", "$", "job", ";", "}" ]
Pushes a job into the queue @param JobInterface $job Job @param array $options ADDJOB options sent to the client @return JobInterface Job pushed
[ "Pushes", "a", "job", "into", "the", "queue" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Queue/Queue.php#L113-L119
228,655
mariano/disque-php
src/Queue/Queue.php
Queue.processing
public function processing(JobInterface $job) { $this->checkConnected(); return $this->client->working($job->getId()); }
php
public function processing(JobInterface $job) { $this->checkConnected(); return $this->client->working($job->getId()); }
[ "public", "function", "processing", "(", "JobInterface", "$", "job", ")", "{", "$", "this", "->", "checkConnected", "(", ")", ";", "return", "$", "this", "->", "client", "->", "working", "(", "$", "job", "->", "getId", "(", ")", ")", ";", "}" ]
Marks that a Job is still being processed @param JobInterface $job Job @return int Number of seconds that the job visibility was postponed
[ "Marks", "that", "a", "Job", "is", "still", "being", "processed" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Queue/Queue.php#L158-L162
228,656
mariano/disque-php
src/Queue/Queue.php
Queue.processed
public function processed(JobInterface $job) { $this->checkConnected(); $this->client->ackJob($job->getId()); }
php
public function processed(JobInterface $job) { $this->checkConnected(); $this->client->ackJob($job->getId()); }
[ "public", "function", "processed", "(", "JobInterface", "$", "job", ")", "{", "$", "this", "->", "checkConnected", "(", ")", ";", "$", "this", "->", "client", "->", "ackJob", "(", "$", "job", "->", "getId", "(", ")", ")", ";", "}" ]
Acknowledges a Job as properly handled @param JobInterface $job Job @return void
[ "Acknowledges", "a", "Job", "as", "properly", "handled" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Queue/Queue.php#L170-L174
228,657
mariano/disque-php
src/Queue/Queue.php
Queue.failed
public function failed(JobInterface $job) { $this->checkConnected(); $this->client->nack($job->getId()); }
php
public function failed(JobInterface $job) { $this->checkConnected(); $this->client->nack($job->getId()); }
[ "public", "function", "failed", "(", "JobInterface", "$", "job", ")", "{", "$", "this", "->", "checkConnected", "(", ")", ";", "$", "this", "->", "client", "->", "nack", "(", "$", "job", "->", "getId", "(", ")", ")", ";", "}" ]
Marks the job as failed and returns it to the queue This increases the NACK counter of the job @param JobInterface $job @return void
[ "Marks", "the", "job", "as", "failed", "and", "returns", "it", "to", "the", "queue" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Queue/Queue.php#L184-L188
228,658
dnunez24/craft-laravel-mix
models/Mix_HotModuleReplacementModel.php
Mix_HotModuleReplacementModel.getAssetPath
public function getAssetPath(string $path) { if (!$this->urlHelper->isFullUrl($path)) { $path = $this->pathHelper->prefix($path); } return $this->urlHelper->getUrl(self::BASE_URL.$path); }
php
public function getAssetPath(string $path) { if (!$this->urlHelper->isFullUrl($path)) { $path = $this->pathHelper->prefix($path); } return $this->urlHelper->getUrl(self::BASE_URL.$path); }
[ "public", "function", "getAssetPath", "(", "string", "$", "path", ")", "{", "if", "(", "!", "$", "this", "->", "urlHelper", "->", "isFullUrl", "(", "$", "path", ")", ")", "{", "$", "path", "=", "$", "this", "->", "pathHelper", "->", "prefix", "(", "$", "path", ")", ";", "}", "return", "$", "this", "->", "urlHelper", "->", "getUrl", "(", "self", "::", "BASE_URL", ".", "$", "path", ")", ";", "}" ]
Get asset path for hot module replacement mode @param string $path @return string
[ "Get", "asset", "path", "for", "hot", "module", "replacement", "mode" ]
c2f060f87be351d30e7d00123bb0ac25dd035490
https://github.com/dnunez24/craft-laravel-mix/blob/c2f060f87be351d30e7d00123bb0ac25dd035490/models/Mix_HotModuleReplacementModel.php#L51-L58
228,659
dnunez24/craft-laravel-mix
models/Mix_HotModuleReplacementModel.php
Mix_HotModuleReplacementModel.isEnabled
public function isEnabled() { $path = $this->directory.'/'.self::FLAG_FILENAME; return (bool)$this->pathHelper->getPublicPath($path); }
php
public function isEnabled() { $path = $this->directory.'/'.self::FLAG_FILENAME; return (bool)$this->pathHelper->getPublicPath($path); }
[ "public", "function", "isEnabled", "(", ")", "{", "$", "path", "=", "$", "this", "->", "directory", ".", "'/'", ".", "self", "::", "FLAG_FILENAME", ";", "return", "(", "bool", ")", "$", "this", "->", "pathHelper", "->", "getPublicPath", "(", "$", "path", ")", ";", "}" ]
Check if hot module replacement mode is enabled @return bool
[ "Check", "if", "hot", "module", "replacement", "mode", "is", "enabled" ]
c2f060f87be351d30e7d00123bb0ac25dd035490
https://github.com/dnunez24/craft-laravel-mix/blob/c2f060f87be351d30e7d00123bb0ac25dd035490/models/Mix_HotModuleReplacementModel.php#L65-L69
228,660
phlib/encrypt
src/Encryptor/OpenSsl.php
OpenSsl.deriveKeys
protected function deriveKeys($salt) { $key = hash_pbkdf2('sha256', $this->password, $salt, $this->pbkdf2Iterations, $this->keyLength * 2, true); return str_split($key, $this->keyLength); }
php
protected function deriveKeys($salt) { $key = hash_pbkdf2('sha256', $this->password, $salt, $this->pbkdf2Iterations, $this->keyLength * 2, true); return str_split($key, $this->keyLength); }
[ "protected", "function", "deriveKeys", "(", "$", "salt", ")", "{", "$", "key", "=", "hash_pbkdf2", "(", "'sha256'", ",", "$", "this", "->", "password", ",", "$", "salt", ",", "$", "this", "->", "pbkdf2Iterations", ",", "$", "this", "->", "keyLength", "*", "2", ",", "true", ")", ";", "return", "str_split", "(", "$", "key", ",", "$", "this", "->", "keyLength", ")", ";", "}" ]
Derive the keys for encryption and authentication using the given salt, and the password @param string $salt @return array
[ "Derive", "the", "keys", "for", "encryption", "and", "authentication", "using", "the", "given", "salt", "and", "the", "password" ]
e13f00a0c517ea8ece37490c4daa896ec29a2503
https://github.com/phlib/encrypt/blob/e13f00a0c517ea8ece37490c4daa896ec29a2503/src/Encryptor/OpenSsl.php#L158-L163
228,661
pear/Net_LDAP2
Net/LDAP2/Schema.php
Net_LDAP2_Schema.fetch
public static function fetch($ldap, $dn = null) { if (!$ldap instanceof Net_LDAP2) { return PEAR::raiseError("Unable to fetch Schema: Parameter \$ldap must be a Net_LDAP2 object!"); } $schema_o = new Net_LDAP2_Schema(); if (is_null($dn)) { // get the subschema entry via root dse $dse = $ldap->rootDSE(array('subschemaSubentry')); if (false == Net_LDAP2::isError($dse)) { $base = $dse->getValue('subschemaSubentry', 'single'); if (!Net_LDAP2::isError($base)) { $dn = $base; } } } // Support for buggy LDAP servers (e.g. Siemens DirX 6.x) that incorrectly // call this entry subSchemaSubentry instead of subschemaSubentry. // Note the correct case/spelling as per RFC 2251. if (is_null($dn)) { // get the subschema entry via root dse $dse = $ldap->rootDSE(array('subSchemaSubentry')); if (false == Net_LDAP2::isError($dse)) { $base = $dse->getValue('subSchemaSubentry', 'single'); if (!Net_LDAP2::isError($base)) { $dn = $base; } } } // Final fallback case where there is no subschemaSubentry attribute // in the root DSE (this is a bug for an LDAP v3 server so report this // to your LDAP vendor if you get this far). if (is_null($dn)) { $dn = 'cn=Subschema'; } // fetch the subschema entry $result = $ldap->search($dn, '(objectClass=*)', array('attributes' => array_values($schema_o->types), 'scope' => 'base')); if (Net_LDAP2::isError($result)) { return PEAR::raiseError('Could not fetch Subschema entry: '.$result->getMessage()); } $entry = $result->shiftEntry(); if (!$entry instanceof Net_LDAP2_Entry) { if ($entry instanceof Net_LDAP2_Error) { return PEAR::raiseError('Could not fetch Subschema entry: '.$entry->getMessage()); } else { return PEAR::raiseError('Could not fetch Subschema entry (search returned '.$result->count().' entries. Check parameter \'basedn\')'); } } $schema_o->parse($entry); return $schema_o; }
php
public static function fetch($ldap, $dn = null) { if (!$ldap instanceof Net_LDAP2) { return PEAR::raiseError("Unable to fetch Schema: Parameter \$ldap must be a Net_LDAP2 object!"); } $schema_o = new Net_LDAP2_Schema(); if (is_null($dn)) { // get the subschema entry via root dse $dse = $ldap->rootDSE(array('subschemaSubentry')); if (false == Net_LDAP2::isError($dse)) { $base = $dse->getValue('subschemaSubentry', 'single'); if (!Net_LDAP2::isError($base)) { $dn = $base; } } } // Support for buggy LDAP servers (e.g. Siemens DirX 6.x) that incorrectly // call this entry subSchemaSubentry instead of subschemaSubentry. // Note the correct case/spelling as per RFC 2251. if (is_null($dn)) { // get the subschema entry via root dse $dse = $ldap->rootDSE(array('subSchemaSubentry')); if (false == Net_LDAP2::isError($dse)) { $base = $dse->getValue('subSchemaSubentry', 'single'); if (!Net_LDAP2::isError($base)) { $dn = $base; } } } // Final fallback case where there is no subschemaSubentry attribute // in the root DSE (this is a bug for an LDAP v3 server so report this // to your LDAP vendor if you get this far). if (is_null($dn)) { $dn = 'cn=Subschema'; } // fetch the subschema entry $result = $ldap->search($dn, '(objectClass=*)', array('attributes' => array_values($schema_o->types), 'scope' => 'base')); if (Net_LDAP2::isError($result)) { return PEAR::raiseError('Could not fetch Subschema entry: '.$result->getMessage()); } $entry = $result->shiftEntry(); if (!$entry instanceof Net_LDAP2_Entry) { if ($entry instanceof Net_LDAP2_Error) { return PEAR::raiseError('Could not fetch Subschema entry: '.$entry->getMessage()); } else { return PEAR::raiseError('Could not fetch Subschema entry (search returned '.$result->count().' entries. Check parameter \'basedn\')'); } } $schema_o->parse($entry); return $schema_o; }
[ "public", "static", "function", "fetch", "(", "$", "ldap", ",", "$", "dn", "=", "null", ")", "{", "if", "(", "!", "$", "ldap", "instanceof", "Net_LDAP2", ")", "{", "return", "PEAR", "::", "raiseError", "(", "\"Unable to fetch Schema: Parameter \\$ldap must be a Net_LDAP2 object!\"", ")", ";", "}", "$", "schema_o", "=", "new", "Net_LDAP2_Schema", "(", ")", ";", "if", "(", "is_null", "(", "$", "dn", ")", ")", "{", "// get the subschema entry via root dse", "$", "dse", "=", "$", "ldap", "->", "rootDSE", "(", "array", "(", "'subschemaSubentry'", ")", ")", ";", "if", "(", "false", "==", "Net_LDAP2", "::", "isError", "(", "$", "dse", ")", ")", "{", "$", "base", "=", "$", "dse", "->", "getValue", "(", "'subschemaSubentry'", ",", "'single'", ")", ";", "if", "(", "!", "Net_LDAP2", "::", "isError", "(", "$", "base", ")", ")", "{", "$", "dn", "=", "$", "base", ";", "}", "}", "}", "// Support for buggy LDAP servers (e.g. Siemens DirX 6.x) that incorrectly", "// call this entry subSchemaSubentry instead of subschemaSubentry.", "// Note the correct case/spelling as per RFC 2251.", "if", "(", "is_null", "(", "$", "dn", ")", ")", "{", "// get the subschema entry via root dse", "$", "dse", "=", "$", "ldap", "->", "rootDSE", "(", "array", "(", "'subSchemaSubentry'", ")", ")", ";", "if", "(", "false", "==", "Net_LDAP2", "::", "isError", "(", "$", "dse", ")", ")", "{", "$", "base", "=", "$", "dse", "->", "getValue", "(", "'subSchemaSubentry'", ",", "'single'", ")", ";", "if", "(", "!", "Net_LDAP2", "::", "isError", "(", "$", "base", ")", ")", "{", "$", "dn", "=", "$", "base", ";", "}", "}", "}", "// Final fallback case where there is no subschemaSubentry attribute", "// in the root DSE (this is a bug for an LDAP v3 server so report this", "// to your LDAP vendor if you get this far).", "if", "(", "is_null", "(", "$", "dn", ")", ")", "{", "$", "dn", "=", "'cn=Subschema'", ";", "}", "// fetch the subschema entry", "$", "result", "=", "$", "ldap", "->", "search", "(", "$", "dn", ",", "'(objectClass=*)'", ",", "array", "(", "'attributes'", "=>", "array_values", "(", "$", "schema_o", "->", "types", ")", ",", "'scope'", "=>", "'base'", ")", ")", ";", "if", "(", "Net_LDAP2", "::", "isError", "(", "$", "result", ")", ")", "{", "return", "PEAR", "::", "raiseError", "(", "'Could not fetch Subschema entry: '", ".", "$", "result", "->", "getMessage", "(", ")", ")", ";", "}", "$", "entry", "=", "$", "result", "->", "shiftEntry", "(", ")", ";", "if", "(", "!", "$", "entry", "instanceof", "Net_LDAP2_Entry", ")", "{", "if", "(", "$", "entry", "instanceof", "Net_LDAP2_Error", ")", "{", "return", "PEAR", "::", "raiseError", "(", "'Could not fetch Subschema entry: '", ".", "$", "entry", "->", "getMessage", "(", ")", ")", ";", "}", "else", "{", "return", "PEAR", "::", "raiseError", "(", "'Could not fetch Subschema entry (search returned '", ".", "$", "result", "->", "count", "(", ")", ".", "' entries. Check parameter \\'basedn\\')'", ")", ";", "}", "}", "$", "schema_o", "->", "parse", "(", "$", "entry", ")", ";", "return", "$", "schema_o", ";", "}" ]
Fetch the Schema from an LDAP connection @param Net_LDAP2 $ldap LDAP connection @param string $dn (optional) Subschema entry dn @access public @return Net_LDAP2_Schema|NET_LDAP2_Error
[ "Fetch", "the", "Schema", "from", "an", "LDAP", "connection" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Schema.php#L126-L185
228,662
pear/Net_LDAP2
Net/LDAP2/Schema.php
Net_LDAP2_Schema.&
public function &getAll($type) { $map = array('objectclasses' => &$this->_objectClasses, 'attributes' => &$this->_attributeTypes, 'ditcontentrules' => &$this->_dITContentRules, 'ditstructurerules' => &$this->_dITStructureRules, 'matchingrules' => &$this->_matchingRules, 'matchingruleuses' => &$this->_matchingRuleUse, 'nameforms' => &$this->_nameForms, 'syntaxes' => &$this->_ldapSyntaxes ); $key = strtolower($type); $ret = ((key_exists($key, $map)) ? $map[$key] : PEAR::raiseError("Unknown type $type")); return $ret; }
php
public function &getAll($type) { $map = array('objectclasses' => &$this->_objectClasses, 'attributes' => &$this->_attributeTypes, 'ditcontentrules' => &$this->_dITContentRules, 'ditstructurerules' => &$this->_dITStructureRules, 'matchingrules' => &$this->_matchingRules, 'matchingruleuses' => &$this->_matchingRuleUse, 'nameforms' => &$this->_nameForms, 'syntaxes' => &$this->_ldapSyntaxes ); $key = strtolower($type); $ret = ((key_exists($key, $map)) ? $map[$key] : PEAR::raiseError("Unknown type $type")); return $ret; }
[ "public", "function", "&", "getAll", "(", "$", "type", ")", "{", "$", "map", "=", "array", "(", "'objectclasses'", "=>", "&", "$", "this", "->", "_objectClasses", ",", "'attributes'", "=>", "&", "$", "this", "->", "_attributeTypes", ",", "'ditcontentrules'", "=>", "&", "$", "this", "->", "_dITContentRules", ",", "'ditstructurerules'", "=>", "&", "$", "this", "->", "_dITStructureRules", ",", "'matchingrules'", "=>", "&", "$", "this", "->", "_matchingRules", ",", "'matchingruleuses'", "=>", "&", "$", "this", "->", "_matchingRuleUse", ",", "'nameforms'", "=>", "&", "$", "this", "->", "_nameForms", ",", "'syntaxes'", "=>", "&", "$", "this", "->", "_ldapSyntaxes", ")", ";", "$", "key", "=", "strtolower", "(", "$", "type", ")", ";", "$", "ret", "=", "(", "(", "key_exists", "(", "$", "key", ",", "$", "map", ")", ")", "?", "$", "map", "[", "$", "key", "]", ":", "PEAR", "::", "raiseError", "(", "\"Unknown type $type\"", ")", ")", ";", "return", "$", "ret", ";", "}" ]
Return a hash of entries for the given type Returns a hash of entry for the givene type. Types may be: objectclasses, attributes, ditcontentrules, ditstructurerules, matchingrules, matchingruleuses, nameforms, syntaxes @param string $type Type to fetch @access public @return array|Net_LDAP2_Error Array or Net_LDAP2_Error
[ "Return", "a", "hash", "of", "entries", "for", "the", "given", "type" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Schema.php#L199-L213
228,663
pear/Net_LDAP2
Net/LDAP2/Schema.php
Net_LDAP2_Schema.&
public function &get($type, $name) { if ($this->_initialized) { $type = strtolower($type); if (false == key_exists($type, $this->types)) { return PEAR::raiseError("No such type $type"); } $name = strtolower($name); $type_var = &$this->{'_' . $this->types[$type]}; if (key_exists($name, $type_var)) { return $type_var[$name]; } elseif (key_exists($name, $this->_oids) && $this->_oids[$name]['type'] == $type) { return $this->_oids[$name]; } else { return PEAR::raiseError("Could not find $type $name"); } } else { $return = null; return $return; } }
php
public function &get($type, $name) { if ($this->_initialized) { $type = strtolower($type); if (false == key_exists($type, $this->types)) { return PEAR::raiseError("No such type $type"); } $name = strtolower($name); $type_var = &$this->{'_' . $this->types[$type]}; if (key_exists($name, $type_var)) { return $type_var[$name]; } elseif (key_exists($name, $this->_oids) && $this->_oids[$name]['type'] == $type) { return $this->_oids[$name]; } else { return PEAR::raiseError("Could not find $type $name"); } } else { $return = null; return $return; } }
[ "public", "function", "&", "get", "(", "$", "type", ",", "$", "name", ")", "{", "if", "(", "$", "this", "->", "_initialized", ")", "{", "$", "type", "=", "strtolower", "(", "$", "type", ")", ";", "if", "(", "false", "==", "key_exists", "(", "$", "type", ",", "$", "this", "->", "types", ")", ")", "{", "return", "PEAR", "::", "raiseError", "(", "\"No such type $type\"", ")", ";", "}", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "$", "type_var", "=", "&", "$", "this", "->", "{", "'_'", ".", "$", "this", "->", "types", "[", "$", "type", "]", "}", ";", "if", "(", "key_exists", "(", "$", "name", ",", "$", "type_var", ")", ")", "{", "return", "$", "type_var", "[", "$", "name", "]", ";", "}", "elseif", "(", "key_exists", "(", "$", "name", ",", "$", "this", "->", "_oids", ")", "&&", "$", "this", "->", "_oids", "[", "$", "name", "]", "[", "'type'", "]", "==", "$", "type", ")", "{", "return", "$", "this", "->", "_oids", "[", "$", "name", "]", ";", "}", "else", "{", "return", "PEAR", "::", "raiseError", "(", "\"Could not find $type $name\"", ")", ";", "}", "}", "else", "{", "$", "return", "=", "null", ";", "return", "$", "return", ";", "}", "}" ]
Return a specific entry @param string $type Type of name @param string $name Name or OID to fetch @access public @return mixed Entry or Net_LDAP2_Error
[ "Return", "a", "specific", "entry" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Schema.php#L224-L246
228,664
pear/Net_LDAP2
Net/LDAP2/Schema.php
Net_LDAP2_Schema._getAttr
protected function _getAttr($oc, $attr) { $oc = strtolower($oc); if (key_exists($oc, $this->_objectClasses) && key_exists($attr, $this->_objectClasses[$oc])) { return $this->_objectClasses[$oc][$attr]; } elseif (key_exists($oc, $this->_oids) && $this->_oids[$oc]['type'] == 'objectclass' && key_exists($attr, $this->_oids[$oc])) { return $this->_oids[$oc][$attr]; } else { return PEAR::raiseError("Could not find $attr attributes for $oc "); } }
php
protected function _getAttr($oc, $attr) { $oc = strtolower($oc); if (key_exists($oc, $this->_objectClasses) && key_exists($attr, $this->_objectClasses[$oc])) { return $this->_objectClasses[$oc][$attr]; } elseif (key_exists($oc, $this->_oids) && $this->_oids[$oc]['type'] == 'objectclass' && key_exists($attr, $this->_oids[$oc])) { return $this->_oids[$oc][$attr]; } else { return PEAR::raiseError("Could not find $attr attributes for $oc "); } }
[ "protected", "function", "_getAttr", "(", "$", "oc", ",", "$", "attr", ")", "{", "$", "oc", "=", "strtolower", "(", "$", "oc", ")", ";", "if", "(", "key_exists", "(", "$", "oc", ",", "$", "this", "->", "_objectClasses", ")", "&&", "key_exists", "(", "$", "attr", ",", "$", "this", "->", "_objectClasses", "[", "$", "oc", "]", ")", ")", "{", "return", "$", "this", "->", "_objectClasses", "[", "$", "oc", "]", "[", "$", "attr", "]", ";", "}", "elseif", "(", "key_exists", "(", "$", "oc", ",", "$", "this", "->", "_oids", ")", "&&", "$", "this", "->", "_oids", "[", "$", "oc", "]", "[", "'type'", "]", "==", "'objectclass'", "&&", "key_exists", "(", "$", "attr", ",", "$", "this", "->", "_oids", "[", "$", "oc", "]", ")", ")", "{", "return", "$", "this", "->", "_oids", "[", "$", "oc", "]", "[", "$", "attr", "]", ";", "}", "else", "{", "return", "PEAR", "::", "raiseError", "(", "\"Could not find $attr attributes for $oc \"", ")", ";", "}", "}" ]
Fetches the given attribute from the given objectclass @param string $oc Name or OID of objectclass @param string $attr Name of attribute to fetch @access protected @return array|Net_LDAP2_Error The attribute or Net_LDAP2_Error
[ "Fetches", "the", "given", "attribute", "from", "the", "given", "objectclass" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Schema.php#L284-L296
228,665
pear/Net_LDAP2
Net/LDAP2/Schema.php
Net_LDAP2_Schema.parse
public function parse(&$entry) { foreach ($this->types as $type => $attr) { // initialize map type to entry $type_var = '_' . $attr; $this->{$type_var} = array(); // get values for this type if ($entry->exists($attr)) { $values = $entry->getValue($attr); if (is_array($values)) { foreach ($values as $value) { unset($schema_entry); // this was a real mess without it // get the schema entry $schema_entry = $this->_parse_entry($value); // set the type $schema_entry['type'] = $type; // save a ref in $_oids $this->_oids[$schema_entry['oid']] = &$schema_entry; // save refs for all names in type map $names = $schema_entry['aliases']; array_push($names, $schema_entry['name']); foreach ($names as $name) { $this->{$type_var}[strtolower($name)] = &$schema_entry; } } } } } $this->_initialized = true; }
php
public function parse(&$entry) { foreach ($this->types as $type => $attr) { // initialize map type to entry $type_var = '_' . $attr; $this->{$type_var} = array(); // get values for this type if ($entry->exists($attr)) { $values = $entry->getValue($attr); if (is_array($values)) { foreach ($values as $value) { unset($schema_entry); // this was a real mess without it // get the schema entry $schema_entry = $this->_parse_entry($value); // set the type $schema_entry['type'] = $type; // save a ref in $_oids $this->_oids[$schema_entry['oid']] = &$schema_entry; // save refs for all names in type map $names = $schema_entry['aliases']; array_push($names, $schema_entry['name']); foreach ($names as $name) { $this->{$type_var}[strtolower($name)] = &$schema_entry; } } } } } $this->_initialized = true; }
[ "public", "function", "parse", "(", "&", "$", "entry", ")", "{", "foreach", "(", "$", "this", "->", "types", "as", "$", "type", "=>", "$", "attr", ")", "{", "// initialize map type to entry", "$", "type_var", "=", "'_'", ".", "$", "attr", ";", "$", "this", "->", "{", "$", "type_var", "}", "=", "array", "(", ")", ";", "// get values for this type", "if", "(", "$", "entry", "->", "exists", "(", "$", "attr", ")", ")", "{", "$", "values", "=", "$", "entry", "->", "getValue", "(", "$", "attr", ")", ";", "if", "(", "is_array", "(", "$", "values", ")", ")", "{", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "unset", "(", "$", "schema_entry", ")", ";", "// this was a real mess without it", "// get the schema entry", "$", "schema_entry", "=", "$", "this", "->", "_parse_entry", "(", "$", "value", ")", ";", "// set the type", "$", "schema_entry", "[", "'type'", "]", "=", "$", "type", ";", "// save a ref in $_oids", "$", "this", "->", "_oids", "[", "$", "schema_entry", "[", "'oid'", "]", "]", "=", "&", "$", "schema_entry", ";", "// save refs for all names in type map", "$", "names", "=", "$", "schema_entry", "[", "'aliases'", "]", ";", "array_push", "(", "$", "names", ",", "$", "schema_entry", "[", "'name'", "]", ")", ";", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "$", "this", "->", "{", "$", "type_var", "}", "[", "strtolower", "(", "$", "name", ")", "]", "=", "&", "$", "schema_entry", ";", "}", "}", "}", "}", "}", "$", "this", "->", "_initialized", "=", "true", ";", "}" ]
Parses the schema of the given Subschema entry @param Net_LDAP2_Entry &$entry Subschema entry @access public @return void
[ "Parses", "the", "schema", "of", "the", "given", "Subschema", "entry" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Schema.php#L323-L358
228,666
pear/Net_LDAP2
Net/LDAP2/Schema.php
Net_LDAP2_Schema.&
protected function &_parse_entry($value) { // tokens that have no value associated $noValue = array('single-value', 'obsolete', 'collective', 'no-user-modification', 'abstract', 'structural', 'auxiliary'); // tokens that can have multiple values $multiValue = array('must', 'may', 'sup'); $schema_entry = array('aliases' => array()); // initilization $tokens = $this->_tokenize($value); // get an array of tokens // remove surrounding brackets if ($tokens[0] == '(') array_shift($tokens); if ($tokens[count($tokens) - 1] == ')') array_pop($tokens); // -1 doesnt work on arrays :-( $schema_entry['oid'] = array_shift($tokens); // first token is the oid // cycle over the tokens until none are left while (count($tokens) > 0) { $token = strtolower(array_shift($tokens)); if (in_array($token, $noValue)) { $schema_entry[$token] = 1; // single value token } else { // this one follows a string or a list if it is multivalued if (($schema_entry[$token] = array_shift($tokens)) == '(') { // this creates the list of values and cycles through the tokens // until the end of the list is reached ')' $schema_entry[$token] = array(); while ($tmp = array_shift($tokens)) { if ($tmp == ')') break; if ($tmp != '$') array_push($schema_entry[$token], $tmp); } } // create a array if the value should be multivalued but was not if (in_array($token, $multiValue) && !is_array($schema_entry[$token])) { $schema_entry[$token] = array($schema_entry[$token]); } } } // get max length from syntax if (key_exists('syntax', $schema_entry)) { if (preg_match('/{(\d+)}/', $schema_entry['syntax'], $matches)) { $schema_entry['max_length'] = $matches[1]; } } // force a name if (empty($schema_entry['name'])) { $schema_entry['name'] = $schema_entry['oid']; } // make one name the default and put the other ones into aliases if (is_array($schema_entry['name'])) { $aliases = $schema_entry['name']; $schema_entry['name'] = array_shift($aliases); $schema_entry['aliases'] = $aliases; } return $schema_entry; }
php
protected function &_parse_entry($value) { // tokens that have no value associated $noValue = array('single-value', 'obsolete', 'collective', 'no-user-modification', 'abstract', 'structural', 'auxiliary'); // tokens that can have multiple values $multiValue = array('must', 'may', 'sup'); $schema_entry = array('aliases' => array()); // initilization $tokens = $this->_tokenize($value); // get an array of tokens // remove surrounding brackets if ($tokens[0] == '(') array_shift($tokens); if ($tokens[count($tokens) - 1] == ')') array_pop($tokens); // -1 doesnt work on arrays :-( $schema_entry['oid'] = array_shift($tokens); // first token is the oid // cycle over the tokens until none are left while (count($tokens) > 0) { $token = strtolower(array_shift($tokens)); if (in_array($token, $noValue)) { $schema_entry[$token] = 1; // single value token } else { // this one follows a string or a list if it is multivalued if (($schema_entry[$token] = array_shift($tokens)) == '(') { // this creates the list of values and cycles through the tokens // until the end of the list is reached ')' $schema_entry[$token] = array(); while ($tmp = array_shift($tokens)) { if ($tmp == ')') break; if ($tmp != '$') array_push($schema_entry[$token], $tmp); } } // create a array if the value should be multivalued but was not if (in_array($token, $multiValue) && !is_array($schema_entry[$token])) { $schema_entry[$token] = array($schema_entry[$token]); } } } // get max length from syntax if (key_exists('syntax', $schema_entry)) { if (preg_match('/{(\d+)}/', $schema_entry['syntax'], $matches)) { $schema_entry['max_length'] = $matches[1]; } } // force a name if (empty($schema_entry['name'])) { $schema_entry['name'] = $schema_entry['oid']; } // make one name the default and put the other ones into aliases if (is_array($schema_entry['name'])) { $aliases = $schema_entry['name']; $schema_entry['name'] = array_shift($aliases); $schema_entry['aliases'] = $aliases; } return $schema_entry; }
[ "protected", "function", "&", "_parse_entry", "(", "$", "value", ")", "{", "// tokens that have no value associated", "$", "noValue", "=", "array", "(", "'single-value'", ",", "'obsolete'", ",", "'collective'", ",", "'no-user-modification'", ",", "'abstract'", ",", "'structural'", ",", "'auxiliary'", ")", ";", "// tokens that can have multiple values", "$", "multiValue", "=", "array", "(", "'must'", ",", "'may'", ",", "'sup'", ")", ";", "$", "schema_entry", "=", "array", "(", "'aliases'", "=>", "array", "(", ")", ")", ";", "// initilization", "$", "tokens", "=", "$", "this", "->", "_tokenize", "(", "$", "value", ")", ";", "// get an array of tokens", "// remove surrounding brackets", "if", "(", "$", "tokens", "[", "0", "]", "==", "'('", ")", "array_shift", "(", "$", "tokens", ")", ";", "if", "(", "$", "tokens", "[", "count", "(", "$", "tokens", ")", "-", "1", "]", "==", "')'", ")", "array_pop", "(", "$", "tokens", ")", ";", "// -1 doesnt work on arrays :-(", "$", "schema_entry", "[", "'oid'", "]", "=", "array_shift", "(", "$", "tokens", ")", ";", "// first token is the oid", "// cycle over the tokens until none are left", "while", "(", "count", "(", "$", "tokens", ")", ">", "0", ")", "{", "$", "token", "=", "strtolower", "(", "array_shift", "(", "$", "tokens", ")", ")", ";", "if", "(", "in_array", "(", "$", "token", ",", "$", "noValue", ")", ")", "{", "$", "schema_entry", "[", "$", "token", "]", "=", "1", ";", "// single value token", "}", "else", "{", "// this one follows a string or a list if it is multivalued", "if", "(", "(", "$", "schema_entry", "[", "$", "token", "]", "=", "array_shift", "(", "$", "tokens", ")", ")", "==", "'('", ")", "{", "// this creates the list of values and cycles through the tokens", "// until the end of the list is reached ')'", "$", "schema_entry", "[", "$", "token", "]", "=", "array", "(", ")", ";", "while", "(", "$", "tmp", "=", "array_shift", "(", "$", "tokens", ")", ")", "{", "if", "(", "$", "tmp", "==", "')'", ")", "break", ";", "if", "(", "$", "tmp", "!=", "'$'", ")", "array_push", "(", "$", "schema_entry", "[", "$", "token", "]", ",", "$", "tmp", ")", ";", "}", "}", "// create a array if the value should be multivalued but was not", "if", "(", "in_array", "(", "$", "token", ",", "$", "multiValue", ")", "&&", "!", "is_array", "(", "$", "schema_entry", "[", "$", "token", "]", ")", ")", "{", "$", "schema_entry", "[", "$", "token", "]", "=", "array", "(", "$", "schema_entry", "[", "$", "token", "]", ")", ";", "}", "}", "}", "// get max length from syntax", "if", "(", "key_exists", "(", "'syntax'", ",", "$", "schema_entry", ")", ")", "{", "if", "(", "preg_match", "(", "'/{(\\d+)}/'", ",", "$", "schema_entry", "[", "'syntax'", "]", ",", "$", "matches", ")", ")", "{", "$", "schema_entry", "[", "'max_length'", "]", "=", "$", "matches", "[", "1", "]", ";", "}", "}", "// force a name", "if", "(", "empty", "(", "$", "schema_entry", "[", "'name'", "]", ")", ")", "{", "$", "schema_entry", "[", "'name'", "]", "=", "$", "schema_entry", "[", "'oid'", "]", ";", "}", "// make one name the default and put the other ones into aliases", "if", "(", "is_array", "(", "$", "schema_entry", "[", "'name'", "]", ")", ")", "{", "$", "aliases", "=", "$", "schema_entry", "[", "'name'", "]", ";", "$", "schema_entry", "[", "'name'", "]", "=", "array_shift", "(", "$", "aliases", ")", ";", "$", "schema_entry", "[", "'aliases'", "]", "=", "$", "aliases", ";", "}", "return", "$", "schema_entry", ";", "}" ]
Parses an attribute value into a schema entry @param string $value Attribute value @access protected @return array|false Schema entry array or false
[ "Parses", "an", "attribute", "value", "into", "a", "schema", "entry" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Schema.php#L368-L431
228,667
pear/Net_LDAP2
Net/LDAP2/Schema.php
Net_LDAP2_Schema._tokenize
protected function _tokenize($value) { $tokens = array(); // array of tokens $matches = array(); // matches[0] full pattern match, [1,2,3] subpatterns // this one is taken from perl-ldap, modified for php $pattern = "/\s* (?:([()]) | ([^'\s()]+) | '((?:[^']+|'[^\s)])*)') \s*/x"; /** * This one matches one big pattern wherin only one of the three subpatterns matched * We are interested in the subpatterns that matched. If it matched its value will be * non-empty and so it is a token. Tokens may be round brackets, a string, or a string * enclosed by ' */ preg_match_all($pattern, $value, $matches); for ($i = 0; $i < count($matches[0]); $i++) { // number of tokens (full pattern match) for ($j = 1; $j < 4; $j++) { // each subpattern if (null != trim($matches[$j][$i])) { // pattern match in this subpattern $tokens[$i] = trim($matches[$j][$i]); // this is the token } } } return $tokens; }
php
protected function _tokenize($value) { $tokens = array(); // array of tokens $matches = array(); // matches[0] full pattern match, [1,2,3] subpatterns // this one is taken from perl-ldap, modified for php $pattern = "/\s* (?:([()]) | ([^'\s()]+) | '((?:[^']+|'[^\s)])*)') \s*/x"; /** * This one matches one big pattern wherin only one of the three subpatterns matched * We are interested in the subpatterns that matched. If it matched its value will be * non-empty and so it is a token. Tokens may be round brackets, a string, or a string * enclosed by ' */ preg_match_all($pattern, $value, $matches); for ($i = 0; $i < count($matches[0]); $i++) { // number of tokens (full pattern match) for ($j = 1; $j < 4; $j++) { // each subpattern if (null != trim($matches[$j][$i])) { // pattern match in this subpattern $tokens[$i] = trim($matches[$j][$i]); // this is the token } } } return $tokens; }
[ "protected", "function", "_tokenize", "(", "$", "value", ")", "{", "$", "tokens", "=", "array", "(", ")", ";", "// array of tokens", "$", "matches", "=", "array", "(", ")", ";", "// matches[0] full pattern match, [1,2,3] subpatterns", "// this one is taken from perl-ldap, modified for php", "$", "pattern", "=", "\"/\\s* (?:([()]) | ([^'\\s()]+) | '((?:[^']+|'[^\\s)])*)') \\s*/x\"", ";", "/**\n * This one matches one big pattern wherin only one of the three subpatterns matched\n * We are interested in the subpatterns that matched. If it matched its value will be\n * non-empty and so it is a token. Tokens may be round brackets, a string, or a string\n * enclosed by '\n */", "preg_match_all", "(", "$", "pattern", ",", "$", "value", ",", "$", "matches", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "matches", "[", "0", "]", ")", ";", "$", "i", "++", ")", "{", "// number of tokens (full pattern match)", "for", "(", "$", "j", "=", "1", ";", "$", "j", "<", "4", ";", "$", "j", "++", ")", "{", "// each subpattern", "if", "(", "null", "!=", "trim", "(", "$", "matches", "[", "$", "j", "]", "[", "$", "i", "]", ")", ")", "{", "// pattern match in this subpattern", "$", "tokens", "[", "$", "i", "]", "=", "trim", "(", "$", "matches", "[", "$", "j", "]", "[", "$", "i", "]", ")", ";", "// this is the token", "}", "}", "}", "return", "$", "tokens", ";", "}" ]
Tokenizes the given value into an array of tokens @param string $value String to parse @access protected @return array Array of tokens
[ "Tokenizes", "the", "given", "value", "into", "an", "array", "of", "tokens" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Schema.php#L441-L465
228,668
pear/Net_LDAP2
Net/LDAP2/Schema.php
Net_LDAP2_Schema.isBinary
public function isBinary($attribute) { $return = false; // default to false // This list contains all syntax that should be treaten as // containing binary values // The Syntax Definitons go into constants at the top of this page $syntax_binary = array( NET_LDAP2_SYNTAX_OCTET_STRING, NET_LDAP2_SYNTAX_JPEG ); // Check Syntax $attr_s = $this->get('attribute', $attribute); if (Net_LDAP2::isError($attr_s)) { // Attribute not found in schema $return = false; // consider attr not binary } elseif (isset($attr_s['syntax']) && in_array($attr_s['syntax'], $syntax_binary)) { // Syntax is defined as binary in schema $return = true; } else { // Syntax not defined as binary, or not found // if attribute is a subtype, check superior attribute syntaxes if (isset($attr_s['sup'])) { foreach ($attr_s['sup'] as $superattr) { $return = $this->isBinary($superattr); if ($return) { break; // stop checking parents since we are binary } } } } return $return; }
php
public function isBinary($attribute) { $return = false; // default to false // This list contains all syntax that should be treaten as // containing binary values // The Syntax Definitons go into constants at the top of this page $syntax_binary = array( NET_LDAP2_SYNTAX_OCTET_STRING, NET_LDAP2_SYNTAX_JPEG ); // Check Syntax $attr_s = $this->get('attribute', $attribute); if (Net_LDAP2::isError($attr_s)) { // Attribute not found in schema $return = false; // consider attr not binary } elseif (isset($attr_s['syntax']) && in_array($attr_s['syntax'], $syntax_binary)) { // Syntax is defined as binary in schema $return = true; } else { // Syntax not defined as binary, or not found // if attribute is a subtype, check superior attribute syntaxes if (isset($attr_s['sup'])) { foreach ($attr_s['sup'] as $superattr) { $return = $this->isBinary($superattr); if ($return) { break; // stop checking parents since we are binary } } } } return $return; }
[ "public", "function", "isBinary", "(", "$", "attribute", ")", "{", "$", "return", "=", "false", ";", "// default to false", "// This list contains all syntax that should be treaten as", "// containing binary values", "// The Syntax Definitons go into constants at the top of this page", "$", "syntax_binary", "=", "array", "(", "NET_LDAP2_SYNTAX_OCTET_STRING", ",", "NET_LDAP2_SYNTAX_JPEG", ")", ";", "// Check Syntax", "$", "attr_s", "=", "$", "this", "->", "get", "(", "'attribute'", ",", "$", "attribute", ")", ";", "if", "(", "Net_LDAP2", "::", "isError", "(", "$", "attr_s", ")", ")", "{", "// Attribute not found in schema", "$", "return", "=", "false", ";", "// consider attr not binary", "}", "elseif", "(", "isset", "(", "$", "attr_s", "[", "'syntax'", "]", ")", "&&", "in_array", "(", "$", "attr_s", "[", "'syntax'", "]", ",", "$", "syntax_binary", ")", ")", "{", "// Syntax is defined as binary in schema", "$", "return", "=", "true", ";", "}", "else", "{", "// Syntax not defined as binary, or not found", "// if attribute is a subtype, check superior attribute syntaxes", "if", "(", "isset", "(", "$", "attr_s", "[", "'sup'", "]", ")", ")", "{", "foreach", "(", "$", "attr_s", "[", "'sup'", "]", "as", "$", "superattr", ")", "{", "$", "return", "=", "$", "this", "->", "isBinary", "(", "$", "superattr", ")", ";", "if", "(", "$", "return", ")", "{", "break", ";", "// stop checking parents since we are binary", "}", "}", "}", "}", "return", "$", "return", ";", "}" ]
Returns wether a attribute syntax is binary or not This method gets used by Net_LDAP2_Entry to decide which PHP function needs to be used to fetch the value in the proper format (e.g. binary or string) @param string $attribute The name of the attribute (eg.: 'sn') @access public @return boolean
[ "Returns", "wether", "a", "attribute", "syntax", "is", "binary", "or", "not" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Schema.php#L479-L513
228,669
pear/Net_LDAP2
Net/LDAP2/Schema.php
Net_LDAP2_Schema.exists
public function exists($type, $name) { $entry = $this->get($type, $name); if ($entry instanceof Net_LDAP2_ERROR) { return false; } else { return true; } }
php
public function exists($type, $name) { $entry = $this->get($type, $name); if ($entry instanceof Net_LDAP2_ERROR) { return false; } else { return true; } }
[ "public", "function", "exists", "(", "$", "type", ",", "$", "name", ")", "{", "$", "entry", "=", "$", "this", "->", "get", "(", "$", "type", ",", "$", "name", ")", ";", "if", "(", "$", "entry", "instanceof", "Net_LDAP2_ERROR", ")", "{", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
See if an schema element exists @param string $type Type of name, see get() @param string $name Name or OID @return boolean
[ "See", "if", "an", "schema", "element", "exists" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Schema.php#L523-L531
228,670
pear/Net_LDAP2
Net/LDAP2/Schema.php
Net_LDAP2_Schema.getAssignedOCLs
public function getAssignedOCLs($attribute) { $may = array(); $must = array(); // Test if the attribute type is defined in the schema, // if so, retrieve real name for lookups $attr_entry = $this->get('attribute', $attribute); if ($attr_entry instanceof Net_LDAP2_ERROR) { return PEAR::raiseError("Attribute $attribute not defined in schema: ".$attr_entry->getMessage()); } else { $attribute = $attr_entry['name']; } // We need to get all defined OCLs for this. $ocls = $this->getAll('objectclasses'); foreach ($ocls as $ocl => $ocl_data) { // Fetch the may and must attrs and see if our searched attr is contained. // If so, record it in the corresponding array. $ocl_may_attrs = $this->may($ocl); $ocl_must_attrs = $this->must($ocl); if (is_array($ocl_may_attrs) && in_array($attribute, $ocl_may_attrs)) { array_push($may, $ocl_data['name']); } if (is_array($ocl_must_attrs) && in_array($attribute, $ocl_must_attrs)) { array_push($must, $ocl_data['name']); } } return array('may' => $may, 'must' => $must); }
php
public function getAssignedOCLs($attribute) { $may = array(); $must = array(); // Test if the attribute type is defined in the schema, // if so, retrieve real name for lookups $attr_entry = $this->get('attribute', $attribute); if ($attr_entry instanceof Net_LDAP2_ERROR) { return PEAR::raiseError("Attribute $attribute not defined in schema: ".$attr_entry->getMessage()); } else { $attribute = $attr_entry['name']; } // We need to get all defined OCLs for this. $ocls = $this->getAll('objectclasses'); foreach ($ocls as $ocl => $ocl_data) { // Fetch the may and must attrs and see if our searched attr is contained. // If so, record it in the corresponding array. $ocl_may_attrs = $this->may($ocl); $ocl_must_attrs = $this->must($ocl); if (is_array($ocl_may_attrs) && in_array($attribute, $ocl_may_attrs)) { array_push($may, $ocl_data['name']); } if (is_array($ocl_must_attrs) && in_array($attribute, $ocl_must_attrs)) { array_push($must, $ocl_data['name']); } } return array('may' => $may, 'must' => $must); }
[ "public", "function", "getAssignedOCLs", "(", "$", "attribute", ")", "{", "$", "may", "=", "array", "(", ")", ";", "$", "must", "=", "array", "(", ")", ";", "// Test if the attribute type is defined in the schema,", "// if so, retrieve real name for lookups", "$", "attr_entry", "=", "$", "this", "->", "get", "(", "'attribute'", ",", "$", "attribute", ")", ";", "if", "(", "$", "attr_entry", "instanceof", "Net_LDAP2_ERROR", ")", "{", "return", "PEAR", "::", "raiseError", "(", "\"Attribute $attribute not defined in schema: \"", ".", "$", "attr_entry", "->", "getMessage", "(", ")", ")", ";", "}", "else", "{", "$", "attribute", "=", "$", "attr_entry", "[", "'name'", "]", ";", "}", "// We need to get all defined OCLs for this.", "$", "ocls", "=", "$", "this", "->", "getAll", "(", "'objectclasses'", ")", ";", "foreach", "(", "$", "ocls", "as", "$", "ocl", "=>", "$", "ocl_data", ")", "{", "// Fetch the may and must attrs and see if our searched attr is contained.", "// If so, record it in the corresponding array.", "$", "ocl_may_attrs", "=", "$", "this", "->", "may", "(", "$", "ocl", ")", ";", "$", "ocl_must_attrs", "=", "$", "this", "->", "must", "(", "$", "ocl", ")", ";", "if", "(", "is_array", "(", "$", "ocl_may_attrs", ")", "&&", "in_array", "(", "$", "attribute", ",", "$", "ocl_may_attrs", ")", ")", "{", "array_push", "(", "$", "may", ",", "$", "ocl_data", "[", "'name'", "]", ")", ";", "}", "if", "(", "is_array", "(", "$", "ocl_must_attrs", ")", "&&", "in_array", "(", "$", "attribute", ",", "$", "ocl_must_attrs", ")", ")", "{", "array_push", "(", "$", "must", ",", "$", "ocl_data", "[", "'name'", "]", ")", ";", "}", "}", "return", "array", "(", "'may'", "=>", "$", "may", ",", "'must'", "=>", "$", "must", ")", ";", "}" ]
See to which ObjectClasses an attribute is assigned The objectclasses are sorted into the keys 'may' and 'must'. @param string $attribute Name or OID of the attribute @return array|Net_LDAP2_Error Associative array with OCL names or Error
[ "See", "to", "which", "ObjectClasses", "an", "attribute", "is", "assigned" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Schema.php#L565-L596
228,671
pear/Net_LDAP2
Net/LDAP2/Schema.php
Net_LDAP2_Schema.checkAttribute
public function checkAttribute($attribute, $ocls) { foreach ($ocls as $ocl) { $ocl_entry = $this->get('objectclass', $ocl); $ocl_may_attrs = $this->may($ocl); $ocl_must_attrs = $this->must($ocl); if (is_array($ocl_may_attrs) && in_array($attribute, $ocl_may_attrs)) { return true; } if (is_array($ocl_must_attrs) && in_array($attribute, $ocl_must_attrs)) { return true; } } return false; // no ocl for the ocls found. }
php
public function checkAttribute($attribute, $ocls) { foreach ($ocls as $ocl) { $ocl_entry = $this->get('objectclass', $ocl); $ocl_may_attrs = $this->may($ocl); $ocl_must_attrs = $this->must($ocl); if (is_array($ocl_may_attrs) && in_array($attribute, $ocl_may_attrs)) { return true; } if (is_array($ocl_must_attrs) && in_array($attribute, $ocl_must_attrs)) { return true; } } return false; // no ocl for the ocls found. }
[ "public", "function", "checkAttribute", "(", "$", "attribute", ",", "$", "ocls", ")", "{", "foreach", "(", "$", "ocls", "as", "$", "ocl", ")", "{", "$", "ocl_entry", "=", "$", "this", "->", "get", "(", "'objectclass'", ",", "$", "ocl", ")", ";", "$", "ocl_may_attrs", "=", "$", "this", "->", "may", "(", "$", "ocl", ")", ";", "$", "ocl_must_attrs", "=", "$", "this", "->", "must", "(", "$", "ocl", ")", ";", "if", "(", "is_array", "(", "$", "ocl_may_attrs", ")", "&&", "in_array", "(", "$", "attribute", ",", "$", "ocl_may_attrs", ")", ")", "{", "return", "true", ";", "}", "if", "(", "is_array", "(", "$", "ocl_must_attrs", ")", "&&", "in_array", "(", "$", "attribute", ",", "$", "ocl_must_attrs", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "// no ocl for the ocls found.", "}" ]
See if an attribute is available in a set of objectClasses @param string $attribute Attribute name or OID @param array $ocls Names of OCLs to check for @return boolean TRUE, if the attribute is defined for at least one of the OCLs
[ "See", "if", "an", "attribute", "is", "available", "in", "a", "set", "of", "objectClasses" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Schema.php#L606-L620
228,672
czim/laravel-cms-upload-module
src/Support/Security/SessionGuard.php
SessionGuard.link
public function link($fileId) { $links = session(static::SESSION_KEY, []); $links[ $fileId ] = true; session()->put(static::SESSION_KEY, $links); return $this; }
php
public function link($fileId) { $links = session(static::SESSION_KEY, []); $links[ $fileId ] = true; session()->put(static::SESSION_KEY, $links); return $this; }
[ "public", "function", "link", "(", "$", "fileId", ")", "{", "$", "links", "=", "session", "(", "static", "::", "SESSION_KEY", ",", "[", "]", ")", ";", "$", "links", "[", "$", "fileId", "]", "=", "true", ";", "session", "(", ")", "->", "put", "(", "static", "::", "SESSION_KEY", ",", "$", "links", ")", ";", "return", "$", "this", ";", "}" ]
Links a given ID to this session. @param int $fileId @return $this
[ "Links", "a", "given", "ID", "to", "this", "session", "." ]
3599801efcfdcf9164e8c75c3e1b2c6e7e3692c3
https://github.com/czim/laravel-cms-upload-module/blob/3599801efcfdcf9164e8c75c3e1b2c6e7e3692c3/src/Support/Security/SessionGuard.php#L32-L41
228,673
czim/laravel-cms-upload-module
src/Support/Security/SessionGuard.php
SessionGuard.unlink
public function unlink($fileId) { if ( ! $this->isIdLinked($fileId)) { return $this; } $links = session(static::SESSION_KEY, []); unset($links[ $fileId ]); session()->put(static::SESSION_KEY, $links); return $this; }
php
public function unlink($fileId) { if ( ! $this->isIdLinked($fileId)) { return $this; } $links = session(static::SESSION_KEY, []); unset($links[ $fileId ]); session()->put(static::SESSION_KEY, $links); return $this; }
[ "public", "function", "unlink", "(", "$", "fileId", ")", "{", "if", "(", "!", "$", "this", "->", "isIdLinked", "(", "$", "fileId", ")", ")", "{", "return", "$", "this", ";", "}", "$", "links", "=", "session", "(", "static", "::", "SESSION_KEY", ",", "[", "]", ")", ";", "unset", "(", "$", "links", "[", "$", "fileId", "]", ")", ";", "session", "(", ")", "->", "put", "(", "static", "::", "SESSION_KEY", ",", "$", "links", ")", ";", "return", "$", "this", ";", "}" ]
Unlinks a given ID from this session. @param int $fileId @return $this
[ "Unlinks", "a", "given", "ID", "from", "this", "session", "." ]
3599801efcfdcf9164e8c75c3e1b2c6e7e3692c3
https://github.com/czim/laravel-cms-upload-module/blob/3599801efcfdcf9164e8c75c3e1b2c6e7e3692c3/src/Support/Security/SessionGuard.php#L49-L62
228,674
dnunez24/craft-laravel-mix
services/MixService.php
MixService.getAssetPath
public function getAssetPath(string $path, $manifestDirectory = '') { $this->setManifestDirectory($manifestDirectory); if ($this->isHotModuleReplacementEnabled()) { return $this->getHotModuleReplacementAssetPath($path); } return $this->getManifestAssetPath($path); }
php
public function getAssetPath(string $path, $manifestDirectory = '') { $this->setManifestDirectory($manifestDirectory); if ($this->isHotModuleReplacementEnabled()) { return $this->getHotModuleReplacementAssetPath($path); } return $this->getManifestAssetPath($path); }
[ "public", "function", "getAssetPath", "(", "string", "$", "path", ",", "$", "manifestDirectory", "=", "''", ")", "{", "$", "this", "->", "setManifestDirectory", "(", "$", "manifestDirectory", ")", ";", "if", "(", "$", "this", "->", "isHotModuleReplacementEnabled", "(", ")", ")", "{", "return", "$", "this", "->", "getHotModuleReplacementAssetPath", "(", "$", "path", ")", ";", "}", "return", "$", "this", "->", "getManifestAssetPath", "(", "$", "path", ")", ";", "}" ]
Get the resolved asset path @param string $path @param string $manifestDirectory @return string
[ "Get", "the", "resolved", "asset", "path" ]
c2f060f87be351d30e7d00123bb0ac25dd035490
https://github.com/dnunez24/craft-laravel-mix/blob/c2f060f87be351d30e7d00123bb0ac25dd035490/services/MixService.php#L39-L48
228,675
dnunez24/craft-laravel-mix
services/MixService.php
MixService.setManifestDirectory
protected function setManifestDirectory(string $manifestDirectory) { $this->manifest->directory = $manifestDirectory; $this->hotModuleReplacement->directory = $manifestDirectory; }
php
protected function setManifestDirectory(string $manifestDirectory) { $this->manifest->directory = $manifestDirectory; $this->hotModuleReplacement->directory = $manifestDirectory; }
[ "protected", "function", "setManifestDirectory", "(", "string", "$", "manifestDirectory", ")", "{", "$", "this", "->", "manifest", "->", "directory", "=", "$", "manifestDirectory", ";", "$", "this", "->", "hotModuleReplacement", "->", "directory", "=", "$", "manifestDirectory", ";", "}" ]
Set the manifest directory for model dependencies @param string $manifestDirectory @return void
[ "Set", "the", "manifest", "directory", "for", "model", "dependencies" ]
c2f060f87be351d30e7d00123bb0ac25dd035490
https://github.com/dnunez24/craft-laravel-mix/blob/c2f060f87be351d30e7d00123bb0ac25dd035490/services/MixService.php#L57-L61
228,676
carpediem/mattermost-webhook
src/Message.php
Message.fromArray
public static function fromArray(array $arr): self { $prop = $arr + (new self($arr['text'] ?? ''))->toArray(); foreach ($prop['attachments'] as &$attachment) { if (!$attachment instanceof AttachmentInterface) { $attachment = Attachment::fromArray($attachment); } } unset($attachment); return self::__set_state($prop); }
php
public static function fromArray(array $arr): self { $prop = $arr + (new self($arr['text'] ?? ''))->toArray(); foreach ($prop['attachments'] as &$attachment) { if (!$attachment instanceof AttachmentInterface) { $attachment = Attachment::fromArray($attachment); } } unset($attachment); return self::__set_state($prop); }
[ "public", "static", "function", "fromArray", "(", "array", "$", "arr", ")", ":", "self", "{", "$", "prop", "=", "$", "arr", "+", "(", "new", "self", "(", "$", "arr", "[", "'text'", "]", "??", "''", ")", ")", "->", "toArray", "(", ")", ";", "foreach", "(", "$", "prop", "[", "'attachments'", "]", "as", "&", "$", "attachment", ")", "{", "if", "(", "!", "$", "attachment", "instanceof", "AttachmentInterface", ")", "{", "$", "attachment", "=", "Attachment", "::", "fromArray", "(", "$", "attachment", ")", ";", "}", "}", "unset", "(", "$", "attachment", ")", ";", "return", "self", "::", "__set_state", "(", "$", "prop", ")", ";", "}" ]
Returns a new instance from an array @param array $arr @return self
[ "Returns", "a", "new", "instance", "from", "an", "array" ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Message.php#L53-L64
228,677
carpediem/mattermost-webhook
src/Message.php
Message.setText
public function setText(string $text): self { $text = trim($text); if ('' === $text) { throw new Exception('The text can not be empty'); } $this->text = $text; return $this; }
php
public function setText(string $text): self { $text = trim($text); if ('' === $text) { throw new Exception('The text can not be empty'); } $this->text = $text; return $this; }
[ "public", "function", "setText", "(", "string", "$", "text", ")", ":", "self", "{", "$", "text", "=", "trim", "(", "$", "text", ")", ";", "if", "(", "''", "===", "$", "text", ")", "{", "throw", "new", "Exception", "(", "'The text can not be empty'", ")", ";", "}", "$", "this", "->", "text", "=", "$", "text", ";", "return", "$", "this", ";", "}" ]
Returns an instance with the specified message text. @param string $text @throws Exception if the text is an empty string @return self
[ "Returns", "an", "instance", "with", "the", "specified", "message", "text", "." ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Message.php#L163-L173
228,678
carpediem/mattermost-webhook
src/Message.php
Message.setAttachments
public function setAttachments($attachments): self { if (!is_iterable($attachments)) { throw new Exception(sprintf('%s() expects argument passed to be iterable, %s given', __METHOD__, gettype($attachments))); } $this->attachments = []; foreach ($attachments as $attachment) { $this->addAttachment($attachment); } return $this; }
php
public function setAttachments($attachments): self { if (!is_iterable($attachments)) { throw new Exception(sprintf('%s() expects argument passed to be iterable, %s given', __METHOD__, gettype($attachments))); } $this->attachments = []; foreach ($attachments as $attachment) { $this->addAttachment($attachment); } return $this; }
[ "public", "function", "setAttachments", "(", "$", "attachments", ")", ":", "self", "{", "if", "(", "!", "is_iterable", "(", "$", "attachments", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'%s() expects argument passed to be iterable, %s given'", ",", "__METHOD__", ",", "gettype", "(", "$", "attachments", ")", ")", ")", ";", "}", "$", "this", "->", "attachments", "=", "[", "]", ";", "foreach", "(", "$", "attachments", "as", "$", "attachment", ")", "{", "$", "this", "->", "addAttachment", "(", "$", "attachment", ")", ";", "}", "return", "$", "this", ";", "}" ]
Override all attachements object with a iterable structure @param array|Traversable $attachments @return self
[ "Override", "all", "attachements", "object", "with", "a", "iterable", "structure" ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Message.php#L238-L250
228,679
coolcsn/CsnCms
src/CsnCms/Controller/TranslationController.php
TranslationController.indexAction
public function indexAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) return $this->redirect()->toRoute('csn-cms/default', array('controller' => 'article', 'action' => 'index')); $entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $dql = "SELECT a, u, l, c, h FROM CsnCms\Entity\Article a LEFT JOIN a.author u LEFT JOIN a.language l LEFT JOIN a.categories c LEFT JOIN a.children h WHERE a.id = ?1"; $query = $entityManager->createQuery($dql); $query->setMaxResults(30); $query->setParameter(1, $id); $articles = $query->getResult(); return new ViewModel(array('articles' => $articles, 'id' => $id)); }
php
public function indexAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) return $this->redirect()->toRoute('csn-cms/default', array('controller' => 'article', 'action' => 'index')); $entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $dql = "SELECT a, u, l, c, h FROM CsnCms\Entity\Article a LEFT JOIN a.author u LEFT JOIN a.language l LEFT JOIN a.categories c LEFT JOIN a.children h WHERE a.id = ?1"; $query = $entityManager->createQuery($dql); $query->setMaxResults(30); $query->setParameter(1, $id); $articles = $query->getResult(); return new ViewModel(array('articles' => $articles, 'id' => $id)); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "id", "=", "(", "int", ")", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'id'", ",", "0", ")", ";", "if", "(", "!", "$", "id", ")", "return", "$", "this", "->", "redirect", "(", ")", "->", "toRoute", "(", "'csn-cms/default'", ",", "array", "(", "'controller'", "=>", "'article'", ",", "'action'", "=>", "'index'", ")", ")", ";", "$", "entityManager", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'doctrine.entitymanager.orm_default'", ")", ";", "$", "dql", "=", "\"SELECT a, u, l, c, h FROM CsnCms\\Entity\\Article a LEFT JOIN a.author u LEFT JOIN a.language l LEFT JOIN a.categories c LEFT JOIN a.children h WHERE a.id = ?1\"", ";", "$", "query", "=", "$", "entityManager", "->", "createQuery", "(", "$", "dql", ")", ";", "$", "query", "->", "setMaxResults", "(", "30", ")", ";", "$", "query", "->", "setParameter", "(", "1", ",", "$", "id", ")", ";", "$", "articles", "=", "$", "query", "->", "getResult", "(", ")", ";", "return", "new", "ViewModel", "(", "array", "(", "'articles'", "=>", "$", "articles", ",", "'id'", "=>", "$", "id", ")", ")", ";", "}" ]
R - retriev
[ "R", "-", "retriev" ]
fd2b163e292836b9f672400694a86f75225b725a
https://github.com/coolcsn/CsnCms/blob/fd2b163e292836b9f672400694a86f75225b725a/src/CsnCms/Controller/TranslationController.php#L24-L37
228,680
pear/Net_LDAP2
Net/LDAP2/Filter.php
Net_LDAP2_Filter.create
public static function create($attr_name, $match, $value = '', $escape = true) { $leaf_filter = new Net_LDAP2_Filter(); if ($escape) { $array = Net_LDAP2_Util::escape_filter_value(array($value)); $value = $array[0]; } $match = strtolower($match); // detect negation $neg_matches = array(); $negate_filter = false; if (preg_match('/^(?:not|!)[\s_-](.+)/', $match, $neg_matches)) { $negate_filter = true; $match = $neg_matches[1]; } // build basic filter switch ($match) { case 'equals': case '=': case '==': $leaf_filter->_filter = '(' . $attr_name . '=' . $value . ')'; break; case 'begins': $leaf_filter->_filter = '(' . $attr_name . '=' . $value . '*)'; break; case 'ends': $leaf_filter->_filter = '(' . $attr_name . '=*' . $value . ')'; break; case 'contains': $leaf_filter->_filter = '(' . $attr_name . '=*' . $value . '*)'; break; case 'greater': case '>': $leaf_filter->_filter = '(' . $attr_name . '>' . $value . ')'; break; case 'less': case '<': $leaf_filter->_filter = '(' . $attr_name . '<' . $value . ')'; break; case 'greaterorequal': case '>=': $leaf_filter->_filter = '(' . $attr_name . '>=' . $value . ')'; break; case 'lessorequal': case '<=': $leaf_filter->_filter = '(' . $attr_name . '<=' . $value . ')'; break; case 'approx': case '~=': $leaf_filter->_filter = '(' . $attr_name . '~=' . $value . ')'; break; case 'any': case 'present': // alias that may improve user code readability $leaf_filter->_filter = '(' . $attr_name . '=*)'; break; default: return PEAR::raiseError('Net_LDAP2_Filter create error: matching rule "' . $match . '" not known!'); } // negate if requested if ($negate_filter) { $leaf_filter = Net_LDAP2_Filter::combine('!', $leaf_filter); } return $leaf_filter; }
php
public static function create($attr_name, $match, $value = '', $escape = true) { $leaf_filter = new Net_LDAP2_Filter(); if ($escape) { $array = Net_LDAP2_Util::escape_filter_value(array($value)); $value = $array[0]; } $match = strtolower($match); // detect negation $neg_matches = array(); $negate_filter = false; if (preg_match('/^(?:not|!)[\s_-](.+)/', $match, $neg_matches)) { $negate_filter = true; $match = $neg_matches[1]; } // build basic filter switch ($match) { case 'equals': case '=': case '==': $leaf_filter->_filter = '(' . $attr_name . '=' . $value . ')'; break; case 'begins': $leaf_filter->_filter = '(' . $attr_name . '=' . $value . '*)'; break; case 'ends': $leaf_filter->_filter = '(' . $attr_name . '=*' . $value . ')'; break; case 'contains': $leaf_filter->_filter = '(' . $attr_name . '=*' . $value . '*)'; break; case 'greater': case '>': $leaf_filter->_filter = '(' . $attr_name . '>' . $value . ')'; break; case 'less': case '<': $leaf_filter->_filter = '(' . $attr_name . '<' . $value . ')'; break; case 'greaterorequal': case '>=': $leaf_filter->_filter = '(' . $attr_name . '>=' . $value . ')'; break; case 'lessorequal': case '<=': $leaf_filter->_filter = '(' . $attr_name . '<=' . $value . ')'; break; case 'approx': case '~=': $leaf_filter->_filter = '(' . $attr_name . '~=' . $value . ')'; break; case 'any': case 'present': // alias that may improve user code readability $leaf_filter->_filter = '(' . $attr_name . '=*)'; break; default: return PEAR::raiseError('Net_LDAP2_Filter create error: matching rule "' . $match . '" not known!'); } // negate if requested if ($negate_filter) { $leaf_filter = Net_LDAP2_Filter::combine('!', $leaf_filter); } return $leaf_filter; }
[ "public", "static", "function", "create", "(", "$", "attr_name", ",", "$", "match", ",", "$", "value", "=", "''", ",", "$", "escape", "=", "true", ")", "{", "$", "leaf_filter", "=", "new", "Net_LDAP2_Filter", "(", ")", ";", "if", "(", "$", "escape", ")", "{", "$", "array", "=", "Net_LDAP2_Util", "::", "escape_filter_value", "(", "array", "(", "$", "value", ")", ")", ";", "$", "value", "=", "$", "array", "[", "0", "]", ";", "}", "$", "match", "=", "strtolower", "(", "$", "match", ")", ";", "// detect negation", "$", "neg_matches", "=", "array", "(", ")", ";", "$", "negate_filter", "=", "false", ";", "if", "(", "preg_match", "(", "'/^(?:not|!)[\\s_-](.+)/'", ",", "$", "match", ",", "$", "neg_matches", ")", ")", "{", "$", "negate_filter", "=", "true", ";", "$", "match", "=", "$", "neg_matches", "[", "1", "]", ";", "}", "// build basic filter", "switch", "(", "$", "match", ")", "{", "case", "'equals'", ":", "case", "'='", ":", "case", "'=='", ":", "$", "leaf_filter", "->", "_filter", "=", "'('", ".", "$", "attr_name", ".", "'='", ".", "$", "value", ".", "')'", ";", "break", ";", "case", "'begins'", ":", "$", "leaf_filter", "->", "_filter", "=", "'('", ".", "$", "attr_name", ".", "'='", ".", "$", "value", ".", "'*)'", ";", "break", ";", "case", "'ends'", ":", "$", "leaf_filter", "->", "_filter", "=", "'('", ".", "$", "attr_name", ".", "'=*'", ".", "$", "value", ".", "')'", ";", "break", ";", "case", "'contains'", ":", "$", "leaf_filter", "->", "_filter", "=", "'('", ".", "$", "attr_name", ".", "'=*'", ".", "$", "value", ".", "'*)'", ";", "break", ";", "case", "'greater'", ":", "case", "'>'", ":", "$", "leaf_filter", "->", "_filter", "=", "'('", ".", "$", "attr_name", ".", "'>'", ".", "$", "value", ".", "')'", ";", "break", ";", "case", "'less'", ":", "case", "'<'", ":", "$", "leaf_filter", "->", "_filter", "=", "'('", ".", "$", "attr_name", ".", "'<'", ".", "$", "value", ".", "')'", ";", "break", ";", "case", "'greaterorequal'", ":", "case", "'>='", ":", "$", "leaf_filter", "->", "_filter", "=", "'('", ".", "$", "attr_name", ".", "'>='", ".", "$", "value", ".", "')'", ";", "break", ";", "case", "'lessorequal'", ":", "case", "'<='", ":", "$", "leaf_filter", "->", "_filter", "=", "'('", ".", "$", "attr_name", ".", "'<='", ".", "$", "value", ".", "')'", ";", "break", ";", "case", "'approx'", ":", "case", "'~='", ":", "$", "leaf_filter", "->", "_filter", "=", "'('", ".", "$", "attr_name", ".", "'~='", ".", "$", "value", ".", "')'", ";", "break", ";", "case", "'any'", ":", "case", "'present'", ":", "// alias that may improve user code readability", "$", "leaf_filter", "->", "_filter", "=", "'('", ".", "$", "attr_name", ".", "'=*)'", ";", "break", ";", "default", ":", "return", "PEAR", "::", "raiseError", "(", "'Net_LDAP2_Filter create error: matching rule \"'", ".", "$", "match", ".", "'\" not known!'", ")", ";", "}", "// negate if requested", "if", "(", "$", "negate_filter", ")", "{", "$", "leaf_filter", "=", "Net_LDAP2_Filter", "::", "combine", "(", "'!'", ",", "$", "leaf_filter", ")", ";", "}", "return", "$", "leaf_filter", ";", "}" ]
Constructor of a new part of a LDAP filter. The following matching rules exists: - equals: One of the attributes values is exactly $value Please note that case sensitiviness is depends on the attributes syntax configured in the server. - begins: One of the attributes values must begin with $value - ends: One of the attributes values must end with $value - contains: One of the attributes values must contain $value - present | any: The attribute can contain any value but must be existent - greater: The attributes value is greater than $value - less: The attributes value is less than $value - greaterOrEqual: The attributes value is greater or equal than $value - lessOrEqual: The attributes value is less or equal than $value - approx: One of the attributes values is similar to $value Negation ("not") can be done by prepending the above operators with the "not" or "!" keyword, see example below. If $escape is set to true (default) then $value will be escaped properly. If it is set to false then $value will be treaten as raw filter value string. You should escape yourself using {@link Net_LDAP2_Util::escape_filter_value()}! Examples: <code> // This will find entries that contain an attribute "sn" that ends with "foobar": $filter = Net_LDAP2_Filter::create('sn', 'ends', 'foobar'); // This will find entries that contain an attribute "sn" that has any value set: $filter = Net_LDAP2_Filter::create('sn', 'any'); // This will build a negated equals filter: $filter = Net_LDAP2_Filter::create('sn', 'not equals', 'foobar'); </code> @param string $attr_name Name of the attribute the filter should apply to @param string $match Matching rule (equals, begins, ends, contains, greater, less, greaterOrEqual, lessOrEqual, approx, any) @param string $value (optional) if given, then this is used as a filter @param boolean $escape Should $value be escaped? (default: yes, see {@link Net_LDAP2_Util::escape_filter_value()} for detailed information) @return Net_LDAP2_Filter|Net_LDAP2_Error
[ "Constructor", "of", "a", "new", "part", "of", "a", "LDAP", "filter", "." ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Filter.php#L164-L232
228,681
pear/Net_LDAP2
Net/LDAP2/Filter.php
Net_LDAP2_Filter.&
public static function &combine($log_op, $filters) { if (PEAR::isError($filters)) { return $filters; } // substitude named operators to logical operators if ($log_op == 'and') $log_op = '&'; if ($log_op == 'or') $log_op = '|'; if ($log_op == 'not') $log_op = '!'; // tests for sane operation if ($log_op == '!') { // Not-combination, here we only accept one filter object or filter string if ($filters instanceof Net_LDAP2_Filter) { $filters = array($filters); // force array } elseif (is_string($filters)) { $filter_o = self::parse($filters); if (PEAR::isError($filter_o)) { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: '.$filter_o->getMessage()); return $err; } else { $filters = array($filter_o); } } elseif (is_array($filters)) { if (count($filters) != 1) { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: operator is "not" but $filter is an array!'); return $err; } elseif (!($filters[0] instanceof Net_LDAP2_Filter)) { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: operator is "not" but $filter is not a valid Net_LDAP2_Filter nor a filter string!'); return $err; } } else { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: operator is "not" but $filter is not a valid Net_LDAP2_Filter nor a filter string!'); return $err; } } elseif ($log_op == '&' || $log_op == '|') { if (!is_array($filters) || count($filters) < 2) { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: parameter $filters is not an array or contains less than two Net_LDAP2_Filter objects!'); return $err; } } else { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: logical operator is not known!'); return $err; } $combined_filter = new Net_LDAP2_Filter(); foreach ($filters as $key => $testfilter) { // check for errors if (PEAR::isError($testfilter)) { return $testfilter; } elseif (is_string($testfilter)) { // string found, try to parse into an filter object $filter_o = self::parse($testfilter); if (PEAR::isError($filter_o)) { return $filter_o; } else { $filters[$key] = $filter_o; } } elseif (!$testfilter instanceof Net_LDAP2_Filter) { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: invalid object passed in array $filters!'); return $err; } } $combined_filter->_subfilters = $filters; $combined_filter->_match = $log_op; return $combined_filter; }
php
public static function &combine($log_op, $filters) { if (PEAR::isError($filters)) { return $filters; } // substitude named operators to logical operators if ($log_op == 'and') $log_op = '&'; if ($log_op == 'or') $log_op = '|'; if ($log_op == 'not') $log_op = '!'; // tests for sane operation if ($log_op == '!') { // Not-combination, here we only accept one filter object or filter string if ($filters instanceof Net_LDAP2_Filter) { $filters = array($filters); // force array } elseif (is_string($filters)) { $filter_o = self::parse($filters); if (PEAR::isError($filter_o)) { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: '.$filter_o->getMessage()); return $err; } else { $filters = array($filter_o); } } elseif (is_array($filters)) { if (count($filters) != 1) { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: operator is "not" but $filter is an array!'); return $err; } elseif (!($filters[0] instanceof Net_LDAP2_Filter)) { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: operator is "not" but $filter is not a valid Net_LDAP2_Filter nor a filter string!'); return $err; } } else { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: operator is "not" but $filter is not a valid Net_LDAP2_Filter nor a filter string!'); return $err; } } elseif ($log_op == '&' || $log_op == '|') { if (!is_array($filters) || count($filters) < 2) { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: parameter $filters is not an array or contains less than two Net_LDAP2_Filter objects!'); return $err; } } else { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: logical operator is not known!'); return $err; } $combined_filter = new Net_LDAP2_Filter(); foreach ($filters as $key => $testfilter) { // check for errors if (PEAR::isError($testfilter)) { return $testfilter; } elseif (is_string($testfilter)) { // string found, try to parse into an filter object $filter_o = self::parse($testfilter); if (PEAR::isError($filter_o)) { return $filter_o; } else { $filters[$key] = $filter_o; } } elseif (!$testfilter instanceof Net_LDAP2_Filter) { $err = PEAR::raiseError('Net_LDAP2_Filter combine error: invalid object passed in array $filters!'); return $err; } } $combined_filter->_subfilters = $filters; $combined_filter->_match = $log_op; return $combined_filter; }
[ "public", "static", "function", "&", "combine", "(", "$", "log_op", ",", "$", "filters", ")", "{", "if", "(", "PEAR", "::", "isError", "(", "$", "filters", ")", ")", "{", "return", "$", "filters", ";", "}", "// substitude named operators to logical operators", "if", "(", "$", "log_op", "==", "'and'", ")", "$", "log_op", "=", "'&'", ";", "if", "(", "$", "log_op", "==", "'or'", ")", "$", "log_op", "=", "'|'", ";", "if", "(", "$", "log_op", "==", "'not'", ")", "$", "log_op", "=", "'!'", ";", "// tests for sane operation", "if", "(", "$", "log_op", "==", "'!'", ")", "{", "// Not-combination, here we only accept one filter object or filter string", "if", "(", "$", "filters", "instanceof", "Net_LDAP2_Filter", ")", "{", "$", "filters", "=", "array", "(", "$", "filters", ")", ";", "// force array", "}", "elseif", "(", "is_string", "(", "$", "filters", ")", ")", "{", "$", "filter_o", "=", "self", "::", "parse", "(", "$", "filters", ")", ";", "if", "(", "PEAR", "::", "isError", "(", "$", "filter_o", ")", ")", "{", "$", "err", "=", "PEAR", "::", "raiseError", "(", "'Net_LDAP2_Filter combine error: '", ".", "$", "filter_o", "->", "getMessage", "(", ")", ")", ";", "return", "$", "err", ";", "}", "else", "{", "$", "filters", "=", "array", "(", "$", "filter_o", ")", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "filters", ")", ")", "{", "if", "(", "count", "(", "$", "filters", ")", "!=", "1", ")", "{", "$", "err", "=", "PEAR", "::", "raiseError", "(", "'Net_LDAP2_Filter combine error: operator is \"not\" but $filter is an array!'", ")", ";", "return", "$", "err", ";", "}", "elseif", "(", "!", "(", "$", "filters", "[", "0", "]", "instanceof", "Net_LDAP2_Filter", ")", ")", "{", "$", "err", "=", "PEAR", "::", "raiseError", "(", "'Net_LDAP2_Filter combine error: operator is \"not\" but $filter is not a valid Net_LDAP2_Filter nor a filter string!'", ")", ";", "return", "$", "err", ";", "}", "}", "else", "{", "$", "err", "=", "PEAR", "::", "raiseError", "(", "'Net_LDAP2_Filter combine error: operator is \"not\" but $filter is not a valid Net_LDAP2_Filter nor a filter string!'", ")", ";", "return", "$", "err", ";", "}", "}", "elseif", "(", "$", "log_op", "==", "'&'", "||", "$", "log_op", "==", "'|'", ")", "{", "if", "(", "!", "is_array", "(", "$", "filters", ")", "||", "count", "(", "$", "filters", ")", "<", "2", ")", "{", "$", "err", "=", "PEAR", "::", "raiseError", "(", "'Net_LDAP2_Filter combine error: parameter $filters is not an array or contains less than two Net_LDAP2_Filter objects!'", ")", ";", "return", "$", "err", ";", "}", "}", "else", "{", "$", "err", "=", "PEAR", "::", "raiseError", "(", "'Net_LDAP2_Filter combine error: logical operator is not known!'", ")", ";", "return", "$", "err", ";", "}", "$", "combined_filter", "=", "new", "Net_LDAP2_Filter", "(", ")", ";", "foreach", "(", "$", "filters", "as", "$", "key", "=>", "$", "testfilter", ")", "{", "// check for errors", "if", "(", "PEAR", "::", "isError", "(", "$", "testfilter", ")", ")", "{", "return", "$", "testfilter", ";", "}", "elseif", "(", "is_string", "(", "$", "testfilter", ")", ")", "{", "// string found, try to parse into an filter object", "$", "filter_o", "=", "self", "::", "parse", "(", "$", "testfilter", ")", ";", "if", "(", "PEAR", "::", "isError", "(", "$", "filter_o", ")", ")", "{", "return", "$", "filter_o", ";", "}", "else", "{", "$", "filters", "[", "$", "key", "]", "=", "$", "filter_o", ";", "}", "}", "elseif", "(", "!", "$", "testfilter", "instanceof", "Net_LDAP2_Filter", ")", "{", "$", "err", "=", "PEAR", "::", "raiseError", "(", "'Net_LDAP2_Filter combine error: invalid object passed in array $filters!'", ")", ";", "return", "$", "err", ";", "}", "}", "$", "combined_filter", "->", "_subfilters", "=", "$", "filters", ";", "$", "combined_filter", "->", "_match", "=", "$", "log_op", ";", "return", "$", "combined_filter", ";", "}" ]
Combine two or more filter objects using a logical operator This static method combines two or more filter objects and returns one single filter object that contains all the others. Call this method statically: $filter = Net_LDAP2_Filter::combine('or', array($filter1, $filter2)) If the array contains filter strings instead of filter objects, we will try to parse them. @param string $log_op The locical operator. May be "and", "or", "not" or the subsequent logical equivalents "&", "|", "!" @param array|Net_LDAP2_Filter $filters array with Net_LDAP2_Filter objects @return Net_LDAP2_Filter|Net_LDAP2_Error @static
[ "Combine", "two", "or", "more", "filter", "objects", "using", "a", "logical", "operator" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Filter.php#L248-L315
228,682
pear/Net_LDAP2
Net/LDAP2/Filter.php
Net_LDAP2_Filter.asString
public function asString() { if ($this->isLeaf()) { $return = $this->_filter; } else { $return = ''; foreach ($this->_subfilters as $filter) { $return = $return.$filter->asString(); } $return = '(' . $this->_match . $return . ')'; } return $return; }
php
public function asString() { if ($this->isLeaf()) { $return = $this->_filter; } else { $return = ''; foreach ($this->_subfilters as $filter) { $return = $return.$filter->asString(); } $return = '(' . $this->_match . $return . ')'; } return $return; }
[ "public", "function", "asString", "(", ")", "{", "if", "(", "$", "this", "->", "isLeaf", "(", ")", ")", "{", "$", "return", "=", "$", "this", "->", "_filter", ";", "}", "else", "{", "$", "return", "=", "''", ";", "foreach", "(", "$", "this", "->", "_subfilters", "as", "$", "filter", ")", "{", "$", "return", "=", "$", "return", ".", "$", "filter", "->", "asString", "(", ")", ";", "}", "$", "return", "=", "'('", ".", "$", "this", "->", "_match", ".", "$", "return", ".", "')'", ";", "}", "return", "$", "return", ";", "}" ]
Get the string representation of this filter This method runs through all filter objects and creates the string representation of the filter. If this filter object is a leaf filter, then it will return the string representation of this filter. @return string|Net_LDAP2_Error
[ "Get", "the", "string", "representation", "of", "this", "filter" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Filter.php#L457-L469
228,683
pear/Net_LDAP2
Net/LDAP2/Filter.php
Net_LDAP2_Filter.printMe
public function printMe($FH = false) { if (!is_resource($FH)) { if (PEAR::isError($FH)) { return $FH; } $filter_str = $this->asString(); if (PEAR::isError($filter_str)) { return $filter_str; } else { print($filter_str); } } else { $filter_str = $this->asString(); if (PEAR::isError($filter_str)) { return $filter_str; } else { $res = @fwrite($FH, $this->asString()); if ($res == false) { return PEAR::raiseError("Unable to write filter string to filehandle \$FH!"); } } } return true; }
php
public function printMe($FH = false) { if (!is_resource($FH)) { if (PEAR::isError($FH)) { return $FH; } $filter_str = $this->asString(); if (PEAR::isError($filter_str)) { return $filter_str; } else { print($filter_str); } } else { $filter_str = $this->asString(); if (PEAR::isError($filter_str)) { return $filter_str; } else { $res = @fwrite($FH, $this->asString()); if ($res == false) { return PEAR::raiseError("Unable to write filter string to filehandle \$FH!"); } } } return true; }
[ "public", "function", "printMe", "(", "$", "FH", "=", "false", ")", "{", "if", "(", "!", "is_resource", "(", "$", "FH", ")", ")", "{", "if", "(", "PEAR", "::", "isError", "(", "$", "FH", ")", ")", "{", "return", "$", "FH", ";", "}", "$", "filter_str", "=", "$", "this", "->", "asString", "(", ")", ";", "if", "(", "PEAR", "::", "isError", "(", "$", "filter_str", ")", ")", "{", "return", "$", "filter_str", ";", "}", "else", "{", "print", "(", "$", "filter_str", ")", ";", "}", "}", "else", "{", "$", "filter_str", "=", "$", "this", "->", "asString", "(", ")", ";", "if", "(", "PEAR", "::", "isError", "(", "$", "filter_str", ")", ")", "{", "return", "$", "filter_str", ";", "}", "else", "{", "$", "res", "=", "@", "fwrite", "(", "$", "FH", ",", "$", "this", "->", "asString", "(", ")", ")", ";", "if", "(", "$", "res", "==", "false", ")", "{", "return", "PEAR", "::", "raiseError", "(", "\"Unable to write filter string to filehandle \\$FH!\"", ")", ";", "}", "}", "}", "return", "true", ";", "}" ]
Print the text representation of the filter to FH, or the currently selected output handle if FH is not given This method is only for compatibility to the perl interface. However, the original method was called "print" but due to PHP language restrictions, we can't have a print() method. @param resource $FH (optional) A filehandle resource @return true|Net_LDAP2_Error
[ "Print", "the", "text", "representation", "of", "the", "filter", "to", "FH", "or", "the", "currently", "selected", "output", "handle", "if", "FH", "is", "not", "given" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Filter.php#L493-L517
228,684
pear/Net_LDAP2
Net/LDAP2/Filter.php
Net_LDAP2_Filter.matches
function matches(&$entries, &$results=array()) { $numOfMatches = 0; if (!is_array($entries)) { $all_entries = array(&$entries); } else { $all_entries = &$entries; } foreach ($all_entries as $entry) { // look at the current entry and see if filter matches $entry_matched = false; // if this is not a single component, do calculate all subfilters, // then assert the partial results with the given combination modifier if (!$this->isLeaf()) { // get partial results from subfilters $partial_results = array(); foreach ($this->_subfilters as $filter) { $partial_results[] = $filter->matches($entry); } // evaluate partial results using this filters combination rule switch ($this->_match) { case '!': // result is the neagtive result of the assertion $entry_matched = !$partial_results[0]; break; case '&': // all partial results have to be boolean-true $entry_matched = !in_array(false, $partial_results); break; case '|': // at least one partial result has to be true $entry_matched = in_array(true, $partial_results); break; } } else { // Leaf filter: assert given entry // [TODO]: Could be optimized to avoid preg_match especially with "ends", "begins" etc // Translate the LDAP-match to some preg_match expression and evaluate it list($attribute, $match, $assertValue) = $this->getComponents(); switch ($match) { case '=': $regexp = '/^'.str_replace('*', '.*', $assertValue).'$/i'; // not case sensitive unless specified by schema $entry_matched = $entry->pregMatch($regexp, $attribute); break; // ------------------------------------- // [TODO]: implement <, >, <=, >= and =~ // ------------------------------------- default: $err = PEAR::raiseError("Net_LDAP2_Filter match error: unsupported match rule '$match'!"); return $err; } } // process filter matching result if ($entry_matched) { $numOfMatches++; $results[] = $entry; } } return $numOfMatches; }
php
function matches(&$entries, &$results=array()) { $numOfMatches = 0; if (!is_array($entries)) { $all_entries = array(&$entries); } else { $all_entries = &$entries; } foreach ($all_entries as $entry) { // look at the current entry and see if filter matches $entry_matched = false; // if this is not a single component, do calculate all subfilters, // then assert the partial results with the given combination modifier if (!$this->isLeaf()) { // get partial results from subfilters $partial_results = array(); foreach ($this->_subfilters as $filter) { $partial_results[] = $filter->matches($entry); } // evaluate partial results using this filters combination rule switch ($this->_match) { case '!': // result is the neagtive result of the assertion $entry_matched = !$partial_results[0]; break; case '&': // all partial results have to be boolean-true $entry_matched = !in_array(false, $partial_results); break; case '|': // at least one partial result has to be true $entry_matched = in_array(true, $partial_results); break; } } else { // Leaf filter: assert given entry // [TODO]: Could be optimized to avoid preg_match especially with "ends", "begins" etc // Translate the LDAP-match to some preg_match expression and evaluate it list($attribute, $match, $assertValue) = $this->getComponents(); switch ($match) { case '=': $regexp = '/^'.str_replace('*', '.*', $assertValue).'$/i'; // not case sensitive unless specified by schema $entry_matched = $entry->pregMatch($regexp, $attribute); break; // ------------------------------------- // [TODO]: implement <, >, <=, >= and =~ // ------------------------------------- default: $err = PEAR::raiseError("Net_LDAP2_Filter match error: unsupported match rule '$match'!"); return $err; } } // process filter matching result if ($entry_matched) { $numOfMatches++; $results[] = $entry; } } return $numOfMatches; }
[ "function", "matches", "(", "&", "$", "entries", ",", "&", "$", "results", "=", "array", "(", ")", ")", "{", "$", "numOfMatches", "=", "0", ";", "if", "(", "!", "is_array", "(", "$", "entries", ")", ")", "{", "$", "all_entries", "=", "array", "(", "&", "$", "entries", ")", ";", "}", "else", "{", "$", "all_entries", "=", "&", "$", "entries", ";", "}", "foreach", "(", "$", "all_entries", "as", "$", "entry", ")", "{", "// look at the current entry and see if filter matches", "$", "entry_matched", "=", "false", ";", "// if this is not a single component, do calculate all subfilters,", "// then assert the partial results with the given combination modifier", "if", "(", "!", "$", "this", "->", "isLeaf", "(", ")", ")", "{", "// get partial results from subfilters", "$", "partial_results", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_subfilters", "as", "$", "filter", ")", "{", "$", "partial_results", "[", "]", "=", "$", "filter", "->", "matches", "(", "$", "entry", ")", ";", "}", "// evaluate partial results using this filters combination rule", "switch", "(", "$", "this", "->", "_match", ")", "{", "case", "'!'", ":", "// result is the neagtive result of the assertion", "$", "entry_matched", "=", "!", "$", "partial_results", "[", "0", "]", ";", "break", ";", "case", "'&'", ":", "// all partial results have to be boolean-true", "$", "entry_matched", "=", "!", "in_array", "(", "false", ",", "$", "partial_results", ")", ";", "break", ";", "case", "'|'", ":", "// at least one partial result has to be true", "$", "entry_matched", "=", "in_array", "(", "true", ",", "$", "partial_results", ")", ";", "break", ";", "}", "}", "else", "{", "// Leaf filter: assert given entry", "// [TODO]: Could be optimized to avoid preg_match especially with \"ends\", \"begins\" etc", "// Translate the LDAP-match to some preg_match expression and evaluate it", "list", "(", "$", "attribute", ",", "$", "match", ",", "$", "assertValue", ")", "=", "$", "this", "->", "getComponents", "(", ")", ";", "switch", "(", "$", "match", ")", "{", "case", "'='", ":", "$", "regexp", "=", "'/^'", ".", "str_replace", "(", "'*'", ",", "'.*'", ",", "$", "assertValue", ")", ".", "'$/i'", ";", "// not case sensitive unless specified by schema", "$", "entry_matched", "=", "$", "entry", "->", "pregMatch", "(", "$", "regexp", ",", "$", "attribute", ")", ";", "break", ";", "// -------------------------------------", "// [TODO]: implement <, >, <=, >= and =~", "// -------------------------------------", "default", ":", "$", "err", "=", "PEAR", "::", "raiseError", "(", "\"Net_LDAP2_Filter match error: unsupported match rule '$match'!\"", ")", ";", "return", "$", "err", ";", "}", "}", "// process filter matching result", "if", "(", "$", "entry_matched", ")", "{", "$", "numOfMatches", "++", ";", "$", "results", "[", "]", "=", "$", "entry", ";", "}", "}", "return", "$", "numOfMatches", ";", "}" ]
Filter entries using this filter or see if a filter matches @todo Currently slow and naive implementation with preg_match, could be optimized (esp. begins, ends filters etc) @todo Currently only "="-based matches (equals, begins, ends, contains, any) implemented; Implement all the stuff! @todo Implement expert code with schema checks in case $entry is connected to a directory @param array|Net_LDAP2_Entry The entry (or array with entries) to check @param array If given, the array will be appended with entries who matched the filter. Return value is true if any entry matched. @return int|Net_LDAP2_Error Returns the number of matched entries or error
[ "Filter", "entries", "using", "this", "filter", "or", "see", "if", "a", "filter", "matches" ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Filter.php#L569-L642
228,685
pear/Net_LDAP2
Net/LDAP2/Filter.php
Net_LDAP2_Filter.getComponents
function getComponents() { if ($this->isLeaf()) { $raw_filter = preg_replace('/^\(|\)$/', '', $this->_filter); $parts = Net_LDAP2_Util::split_attribute_string($raw_filter, true, true); if (count($parts) != 3) { return PEAR::raiseError("Net_LDAP2_Filter getComponents() error: invalid filter syntax - unknown matching rule used"); } else { return $parts; } } else { return PEAR::raiseError('Net_LDAP2_Filter getComponents() call is invalid for non-leaf filters!'); } }
php
function getComponents() { if ($this->isLeaf()) { $raw_filter = preg_replace('/^\(|\)$/', '', $this->_filter); $parts = Net_LDAP2_Util::split_attribute_string($raw_filter, true, true); if (count($parts) != 3) { return PEAR::raiseError("Net_LDAP2_Filter getComponents() error: invalid filter syntax - unknown matching rule used"); } else { return $parts; } } else { return PEAR::raiseError('Net_LDAP2_Filter getComponents() call is invalid for non-leaf filters!'); } }
[ "function", "getComponents", "(", ")", "{", "if", "(", "$", "this", "->", "isLeaf", "(", ")", ")", "{", "$", "raw_filter", "=", "preg_replace", "(", "'/^\\(|\\)$/'", ",", "''", ",", "$", "this", "->", "_filter", ")", ";", "$", "parts", "=", "Net_LDAP2_Util", "::", "split_attribute_string", "(", "$", "raw_filter", ",", "true", ",", "true", ")", ";", "if", "(", "count", "(", "$", "parts", ")", "!=", "3", ")", "{", "return", "PEAR", "::", "raiseError", "(", "\"Net_LDAP2_Filter getComponents() error: invalid filter syntax - unknown matching rule used\"", ")", ";", "}", "else", "{", "return", "$", "parts", ";", "}", "}", "else", "{", "return", "PEAR", "::", "raiseError", "(", "'Net_LDAP2_Filter getComponents() call is invalid for non-leaf filters!'", ")", ";", "}", "}" ]
Retrieve this leaf-filters attribute, match and value component. For leaf filters, this returns array(attr, match, value). Match is be the logical operator, not the text representation, eg "=" instead of "equals". Note that some operators are really a combination of operator+value with wildcard, like "begins": That will return "=" with the value "value*"! For non-leaf filters this will drop an error. @todo $this->_match is not always available and thus not usable here; it would be great if it would set in the factory methods and constructor. @return array|Net_LDAP2_Error
[ "Retrieve", "this", "leaf", "-", "filters", "attribute", "match", "and", "value", "component", "." ]
38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8
https://github.com/pear/Net_LDAP2/blob/38f1b22a96dfbd7ec53852f0e1e7ec1a9a5eb0e8/Net/LDAP2/Filter.php#L659-L671
228,686
mariano/disque-php
src/Command/BaseCommand.php
BaseCommand.toArguments
protected function toArguments(array $options) { if (empty($options)) { return []; } elseif (!empty(array_diff_key($options, $this->availableArguments))) { throw new InvalidOptionException($this, $options); } // Pad, don't overwrite, the client provided options with the default ones $options += $this->options; $arguments = []; foreach ($this->availableArguments as $option => $argument) { if (!isset($options[$option]) || $options[$option] === false) { continue; } $value = $options[$option]; if (is_array($value)) { foreach ($value as $currentValue) { $arguments[] = $argument; $arguments[] = $currentValue; } } else { $arguments[] = $argument; if (!is_bool($value)) { $arguments[] = $value; } } } return $arguments; }
php
protected function toArguments(array $options) { if (empty($options)) { return []; } elseif (!empty(array_diff_key($options, $this->availableArguments))) { throw new InvalidOptionException($this, $options); } // Pad, don't overwrite, the client provided options with the default ones $options += $this->options; $arguments = []; foreach ($this->availableArguments as $option => $argument) { if (!isset($options[$option]) || $options[$option] === false) { continue; } $value = $options[$option]; if (is_array($value)) { foreach ($value as $currentValue) { $arguments[] = $argument; $arguments[] = $currentValue; } } else { $arguments[] = $argument; if (!is_bool($value)) { $arguments[] = $value; } } } return $arguments; }
[ "protected", "function", "toArguments", "(", "array", "$", "options", ")", "{", "if", "(", "empty", "(", "$", "options", ")", ")", "{", "return", "[", "]", ";", "}", "elseif", "(", "!", "empty", "(", "array_diff_key", "(", "$", "options", ",", "$", "this", "->", "availableArguments", ")", ")", ")", "{", "throw", "new", "InvalidOptionException", "(", "$", "this", ",", "$", "options", ")", ";", "}", "// Pad, don't overwrite, the client provided options with the default ones", "$", "options", "+=", "$", "this", "->", "options", ";", "$", "arguments", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "availableArguments", "as", "$", "option", "=>", "$", "argument", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "$", "option", "]", ")", "||", "$", "options", "[", "$", "option", "]", "===", "false", ")", "{", "continue", ";", "}", "$", "value", "=", "$", "options", "[", "$", "option", "]", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "currentValue", ")", "{", "$", "arguments", "[", "]", "=", "$", "argument", ";", "$", "arguments", "[", "]", "=", "$", "currentValue", ";", "}", "}", "else", "{", "$", "arguments", "[", "]", "=", "$", "argument", ";", "if", "(", "!", "is_bool", "(", "$", "value", ")", ")", "{", "$", "arguments", "[", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "arguments", ";", "}" ]
Build command arguments out of options Client-supplied options are amended with the default options defined in $this->options. Options whose value is set to null or false are ignored @param array $options Command options @return array Command arguments @throws InvalidOptionException
[ "Build", "command", "arguments", "out", "of", "options" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Command/BaseCommand.php#L181-L212
228,687
carpediem/mattermost-webhook
src/Client.php
Client.send
public function send($url, Message $message, array $options = []): ResponseInterface { try { unset($options['body']); $options['json'] = $message; $options['Content-Type'] = 'application/json'; return $this->client->request('POST', $url, $options); } catch (Throwable $e) { throw new Exception($e->getMessage(), $e->getCode(), $e); } }
php
public function send($url, Message $message, array $options = []): ResponseInterface { try { unset($options['body']); $options['json'] = $message; $options['Content-Type'] = 'application/json'; return $this->client->request('POST', $url, $options); } catch (Throwable $e) { throw new Exception($e->getMessage(), $e->getCode(), $e); } }
[ "public", "function", "send", "(", "$", "url", ",", "Message", "$", "message", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ResponseInterface", "{", "try", "{", "unset", "(", "$", "options", "[", "'body'", "]", ")", ";", "$", "options", "[", "'json'", "]", "=", "$", "message", ";", "$", "options", "[", "'Content-Type'", "]", "=", "'application/json'", ";", "return", "$", "this", "->", "client", "->", "request", "(", "'POST'", ",", "$", "url", ",", "$", "options", ")", ";", "}", "catch", "(", "Throwable", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", ")", ";", "}", "}" ]
Send a message to a Mattermost Webhook DEPRECATION WARNING! This method will be removed in the next major point release @deprecated deprecated since version 1.1.0 @see Client::notify @param string|UriInterface $url @param MessageInterface $message @param array $options additionals Guzzle options @throws Exception @return ResponseInterface
[ "Send", "a", "message", "to", "a", "Mattermost", "Webhook" ]
9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833
https://github.com/carpediem/mattermost-webhook/blob/9192dbdd8150d7579e3f06da1cbf5bd4d1f8b833/src/Client.php#L76-L87
228,688
coolcsn/CsnCms
src/CsnCms/Entity/Article.php
Article.addChildren
public function addChildren(Collection $children) { foreach ($children as $child) { $this->addChild($child); } return $this; }
php
public function addChildren(Collection $children) { foreach ($children as $child) { $this->addChild($child); } return $this; }
[ "public", "function", "addChildren", "(", "Collection", "$", "children", ")", "{", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "this", "->", "addChild", "(", "$", "child", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add Child - translation @param Collection $children @return Article
[ "Add", "Child", "-", "translation" ]
fd2b163e292836b9f672400694a86f75225b725a
https://github.com/coolcsn/CsnCms/blob/fd2b163e292836b9f672400694a86f75225b725a/src/CsnCms/Entity/Article.php#L520-L527
228,689
contao-bootstrap/templates
src/EventListener/NavClassListener.php
NavClassListener.onIsVisibleElement
public function onIsVisibleElement(Model $element, $isVisible): bool { $isVisible = (bool) $isVisible; // load module if it is a module include element if ($element instanceof ContentModel && $element->type == 'module') { $element = ModuleModel::findByPK($element->module); } if (!$element instanceof ModuleModel) { return $isVisible; } // do not limit for navigation module. so every module can access it $this->navClass = $element->bs_nav_class; return $isVisible; }
php
public function onIsVisibleElement(Model $element, $isVisible): bool { $isVisible = (bool) $isVisible; // load module if it is a module include element if ($element instanceof ContentModel && $element->type == 'module') { $element = ModuleModel::findByPK($element->module); } if (!$element instanceof ModuleModel) { return $isVisible; } // do not limit for navigation module. so every module can access it $this->navClass = $element->bs_nav_class; return $isVisible; }
[ "public", "function", "onIsVisibleElement", "(", "Model", "$", "element", ",", "$", "isVisible", ")", ":", "bool", "{", "$", "isVisible", "=", "(", "bool", ")", "$", "isVisible", ";", "// load module if it is a module include element", "if", "(", "$", "element", "instanceof", "ContentModel", "&&", "$", "element", "->", "type", "==", "'module'", ")", "{", "$", "element", "=", "ModuleModel", "::", "findByPK", "(", "$", "element", "->", "module", ")", ";", "}", "if", "(", "!", "$", "element", "instanceof", "ModuleModel", ")", "{", "return", "$", "isVisible", ";", "}", "// do not limit for navigation module. so every module can access it", "$", "this", "->", "navClass", "=", "$", "element", "->", "bs_nav_class", ";", "return", "$", "isVisible", ";", "}" ]
Check if a module is loaded which make use the bs_nav_class value. @param Model $element The given element. @param bool $isVisible Visibility state. @return bool
[ "Check", "if", "a", "module", "is", "loaded", "which", "make", "use", "the", "bs_nav_class", "value", "." ]
cf507af3a194895923c6b84d97aa224e8b5b6d2f
https://github.com/contao-bootstrap/templates/blob/cf507af3a194895923c6b84d97aa224e8b5b6d2f/src/EventListener/NavClassListener.php#L43-L60
228,690
contao-bootstrap/templates
src/EventListener/NavClassListener.php
NavClassListener.onParseTemplate
public function onParseTemplate(Template $template): void { if (substr($template->getName(), 0, 4) !== 'nav_') { return; } $template->navClass = (string) $this->navClass; }
php
public function onParseTemplate(Template $template): void { if (substr($template->getName(), 0, 4) !== 'nav_') { return; } $template->navClass = (string) $this->navClass; }
[ "public", "function", "onParseTemplate", "(", "Template", "$", "template", ")", ":", "void", "{", "if", "(", "substr", "(", "$", "template", "->", "getName", "(", ")", ",", "0", ",", "4", ")", "!==", "'nav_'", ")", "{", "return", ";", "}", "$", "template", "->", "navClass", "=", "(", "string", ")", "$", "this", "->", "navClass", ";", "}" ]
Set the nav class in the nav template. @param Template $template The template being parsed. @return void
[ "Set", "the", "nav", "class", "in", "the", "nav", "template", "." ]
cf507af3a194895923c6b84d97aa224e8b5b6d2f
https://github.com/contao-bootstrap/templates/blob/cf507af3a194895923c6b84d97aa224e8b5b6d2f/src/EventListener/NavClassListener.php#L69-L76
228,691
mariano/disque-php
src/Command/Argument/OptionChecker.php
OptionChecker.checkOptionsInt
protected function checkOptionsInt(array $options, array $keys) { foreach ($keys as $intOption) { if (isset($options[$intOption]) && !is_int($options[$intOption])) { throw new InvalidOptionException($this, $options); } } }
php
protected function checkOptionsInt(array $options, array $keys) { foreach ($keys as $intOption) { if (isset($options[$intOption]) && !is_int($options[$intOption])) { throw new InvalidOptionException($this, $options); } } }
[ "protected", "function", "checkOptionsInt", "(", "array", "$", "options", ",", "array", "$", "keys", ")", "{", "foreach", "(", "$", "keys", "as", "$", "intOption", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "$", "intOption", "]", ")", "&&", "!", "is_int", "(", "$", "options", "[", "$", "intOption", "]", ")", ")", "{", "throw", "new", "InvalidOptionException", "(", "$", "this", ",", "$", "options", ")", ";", "}", "}", "}" ]
Checks an array so that their keys are ints @param array $options Options @param array $keys Keys to check @throw InvalidOptionException
[ "Checks", "an", "array", "so", "that", "their", "keys", "are", "ints" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Command/Argument/OptionChecker.php#L15-L22
228,692
mariano/disque-php
src/Command/Argument/OptionChecker.php
OptionChecker.checkOptionsString
protected function checkOptionsString(array $options, array $keys) { foreach ($keys as $intOption) { if (isset($options[$intOption]) && !is_string($options[$intOption])) { throw new InvalidOptionException($this, $options); } } }
php
protected function checkOptionsString(array $options, array $keys) { foreach ($keys as $intOption) { if (isset($options[$intOption]) && !is_string($options[$intOption])) { throw new InvalidOptionException($this, $options); } } }
[ "protected", "function", "checkOptionsString", "(", "array", "$", "options", ",", "array", "$", "keys", ")", "{", "foreach", "(", "$", "keys", "as", "$", "intOption", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "$", "intOption", "]", ")", "&&", "!", "is_string", "(", "$", "options", "[", "$", "intOption", "]", ")", ")", "{", "throw", "new", "InvalidOptionException", "(", "$", "this", ",", "$", "options", ")", ";", "}", "}", "}" ]
Checks an array so that their keys are strings @param array $options Options @param array $keys Keys to check @throw InvalidOptionException
[ "Checks", "an", "array", "so", "that", "their", "keys", "are", "strings" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Command/Argument/OptionChecker.php#L31-L38
228,693
mariano/disque-php
src/Command/Argument/OptionChecker.php
OptionChecker.checkOptionsArray
protected function checkOptionsArray(array $options, array $keys) { foreach ($keys as $intOption) { if (isset($options[$intOption]) && !is_array($options[$intOption])) { throw new InvalidOptionException($this, $options); } } }
php
protected function checkOptionsArray(array $options, array $keys) { foreach ($keys as $intOption) { if (isset($options[$intOption]) && !is_array($options[$intOption])) { throw new InvalidOptionException($this, $options); } } }
[ "protected", "function", "checkOptionsArray", "(", "array", "$", "options", ",", "array", "$", "keys", ")", "{", "foreach", "(", "$", "keys", "as", "$", "intOption", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "$", "intOption", "]", ")", "&&", "!", "is_array", "(", "$", "options", "[", "$", "intOption", "]", ")", ")", "{", "throw", "new", "InvalidOptionException", "(", "$", "this", ",", "$", "options", ")", ";", "}", "}", "}" ]
Checks an array so that their keys are arrays @param array $options Options @param array $keys Keys to check @throw InvalidOptionException
[ "Checks", "an", "array", "so", "that", "their", "keys", "are", "arrays" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Command/Argument/OptionChecker.php#L47-L54
228,694
hash-bang/RefLib
reflib.php
RefLib.LoadDriver
function LoadDriver($driver) { $driver = strtolower($driver); if ($driver == $this->_activeDriver) // Already loaded this driver return TRUE; if (!file_exists($file = dirname(__FILE__) . "/drivers/$driver.php")) return; require_once($file); $driverName = "RefLib_" . ucfirst($driver); $this->driver = new $driverName(); $this->driver->parent = $this; $this->_activeDriver = $driver; return TRUE; }
php
function LoadDriver($driver) { $driver = strtolower($driver); if ($driver == $this->_activeDriver) // Already loaded this driver return TRUE; if (!file_exists($file = dirname(__FILE__) . "/drivers/$driver.php")) return; require_once($file); $driverName = "RefLib_" . ucfirst($driver); $this->driver = new $driverName(); $this->driver->parent = $this; $this->_activeDriver = $driver; return TRUE; }
[ "function", "LoadDriver", "(", "$", "driver", ")", "{", "$", "driver", "=", "strtolower", "(", "$", "driver", ")", ";", "if", "(", "$", "driver", "==", "$", "this", "->", "_activeDriver", ")", "// Already loaded this driver", "return", "TRUE", ";", "if", "(", "!", "file_exists", "(", "$", "file", "=", "dirname", "(", "__FILE__", ")", ".", "\"/drivers/$driver.php\"", ")", ")", "return", ";", "require_once", "(", "$", "file", ")", ";", "$", "driverName", "=", "\"RefLib_\"", ".", "ucfirst", "(", "$", "driver", ")", ";", "$", "this", "->", "driver", "=", "new", "$", "driverName", "(", ")", ";", "$", "this", "->", "driver", "->", "parent", "=", "$", "this", ";", "$", "this", "->", "_activeDriver", "=", "$", "driver", ";", "return", "TRUE", ";", "}" ]
Load a specific driver @param string $driver The name of the driver to load. This should correspond to the driver name in drivers/*.php @return bool TRUE if the driver is valid OR already loaded, FALSE if the driver cannot be loaded
[ "Load", "a", "specific", "driver" ]
f53998da9adb36906fdc766c5043ddbe60f2310b
https://github.com/hash-bang/RefLib/blob/f53998da9adb36906fdc766c5043ddbe60f2310b/reflib.php#L118-L130
228,695
hash-bang/RefLib
reflib.php
RefLib.IdentifyDriver
function IdentifyDriver() { $types = func_get_args(); foreach ($types as $type) { switch ($type) { case 'xml': case 'text/xml': return 'endnotexml'; case 'ris': return 'ris'; case 'csv': case 'text/csv': return 'csv'; case 'medline': case 'nbib': return 'medline'; default: // General file if (is_file($type)) { if ( function_exists('mime_content_type') && $mime = mime_content_type($type) ) { if ($type == 'text/csv') return 'csv'; if ($type == 'application/nbib') return 'medline'; } // Still no idea - try internal tests $preview = $this->_SlurpPeek($type); if (preg_match('/^TY - /ms', $preview)) return 'ris'; if (preg_match('/^PMID- /ms', $preview)) return 'medline'; } } } }
php
function IdentifyDriver() { $types = func_get_args(); foreach ($types as $type) { switch ($type) { case 'xml': case 'text/xml': return 'endnotexml'; case 'ris': return 'ris'; case 'csv': case 'text/csv': return 'csv'; case 'medline': case 'nbib': return 'medline'; default: // General file if (is_file($type)) { if ( function_exists('mime_content_type') && $mime = mime_content_type($type) ) { if ($type == 'text/csv') return 'csv'; if ($type == 'application/nbib') return 'medline'; } // Still no idea - try internal tests $preview = $this->_SlurpPeek($type); if (preg_match('/^TY - /ms', $preview)) return 'ris'; if (preg_match('/^PMID- /ms', $preview)) return 'medline'; } } } }
[ "function", "IdentifyDriver", "(", ")", "{", "$", "types", "=", "func_get_args", "(", ")", ";", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'xml'", ":", "case", "'text/xml'", ":", "return", "'endnotexml'", ";", "case", "'ris'", ":", "return", "'ris'", ";", "case", "'csv'", ":", "case", "'text/csv'", ":", "return", "'csv'", ";", "case", "'medline'", ":", "case", "'nbib'", ":", "return", "'medline'", ";", "default", ":", "// General file", "if", "(", "is_file", "(", "$", "type", ")", ")", "{", "if", "(", "function_exists", "(", "'mime_content_type'", ")", "&&", "$", "mime", "=", "mime_content_type", "(", "$", "type", ")", ")", "{", "if", "(", "$", "type", "==", "'text/csv'", ")", "return", "'csv'", ";", "if", "(", "$", "type", "==", "'application/nbib'", ")", "return", "'medline'", ";", "}", "// Still no idea - try internal tests", "$", "preview", "=", "$", "this", "->", "_SlurpPeek", "(", "$", "type", ")", ";", "if", "(", "preg_match", "(", "'/^TY - /ms'", ",", "$", "preview", ")", ")", "return", "'ris'", ";", "if", "(", "preg_match", "(", "'/^PMID- /ms'", ",", "$", "preview", ")", ")", "return", "'medline'", ";", "}", "}", "}", "}" ]
Tries to identify the correct driver to use based on an array of data @param array $types,... An array of known data about the file. Usually this is the file extension (if any) and mime type @return string Either a suitable driver name or boolean false
[ "Tries", "to", "identify", "the", "correct", "driver", "to", "use", "based", "on", "an", "array", "of", "data" ]
f53998da9adb36906fdc766c5043ddbe60f2310b
https://github.com/hash-bang/RefLib/blob/f53998da9adb36906fdc766c5043ddbe60f2310b/reflib.php#L149-L181
228,696
hash-bang/RefLib
reflib.php
RefLib.DownloadContents
function DownloadContents($filename = null, $driver = null) { if ($filename && $driver) { $this->LoadDriver($driver); } elseif ($filename) { // $filename but no $driver - identify it from the filename if (! $driver = $this->IdentifyDriver($filename)) { trigger_error("Unknown reference driver to use with filename '$filename'"); } else { $this->LoadDriver($driver); } } else { $filename = $this->driver->GetFilename(); } header('Content-type: text/plain'); header('Content-Disposition: attachment; filename="' . $filename . '"'); echo $this->driver->GetContents(); }
php
function DownloadContents($filename = null, $driver = null) { if ($filename && $driver) { $this->LoadDriver($driver); } elseif ($filename) { // $filename but no $driver - identify it from the filename if (! $driver = $this->IdentifyDriver($filename)) { trigger_error("Unknown reference driver to use with filename '$filename'"); } else { $this->LoadDriver($driver); } } else { $filename = $this->driver->GetFilename(); } header('Content-type: text/plain'); header('Content-Disposition: attachment; filename="' . $filename . '"'); echo $this->driver->GetContents(); }
[ "function", "DownloadContents", "(", "$", "filename", "=", "null", ",", "$", "driver", "=", "null", ")", "{", "if", "(", "$", "filename", "&&", "$", "driver", ")", "{", "$", "this", "->", "LoadDriver", "(", "$", "driver", ")", ";", "}", "elseif", "(", "$", "filename", ")", "{", "// $filename but no $driver - identify it from the filename", "if", "(", "!", "$", "driver", "=", "$", "this", "->", "IdentifyDriver", "(", "$", "filename", ")", ")", "{", "trigger_error", "(", "\"Unknown reference driver to use with filename '$filename'\"", ")", ";", "}", "else", "{", "$", "this", "->", "LoadDriver", "(", "$", "driver", ")", ";", "}", "}", "else", "{", "$", "filename", "=", "$", "this", "->", "driver", "->", "GetFilename", "(", ")", ";", "}", "header", "(", "'Content-type: text/plain'", ")", ";", "header", "(", "'Content-Disposition: attachment; filename=\"'", ".", "$", "filename", ".", "'\"'", ")", ";", "echo", "$", "this", "->", "driver", "->", "GetContents", "(", ")", ";", "}" ]
Generate an XML file and output it to the browser This will force the user to save the file somewhere to be opened later by EndNote @param string $filename The default filename to save as, if unspecifed the driver default will be used. The filename will be used with IdentifyDriver() if $driver is unspecified @param string $driver The driver to use when outputting the file, if this setting is omitted the $filename will be used to compute the correct driver to use @return blob The raw file contents streamed directly to the browser
[ "Generate", "an", "XML", "file", "and", "output", "it", "to", "the", "browser", "This", "will", "force", "the", "user", "to", "save", "the", "file", "somewhere", "to", "be", "opened", "later", "by", "EndNote" ]
f53998da9adb36906fdc766c5043ddbe60f2310b
https://github.com/hash-bang/RefLib/blob/f53998da9adb36906fdc766c5043ddbe60f2310b/reflib.php#L245-L260
228,697
hash-bang/RefLib
reflib.php
RefLib.ToEpoc
function ToEpoc($date, $ref = null) { if (preg_match('!^[0-9]{10,}$!', $date)) { // Unix time stamp return $date; } else if (preg_match('!^[0-9]{4}$!', $date)) { // Just year return strtotime("$date-01-01"); } else if (preg_match('!^[0-9]{4}-[0-9]{2}$!', $date)) { // Year + month return strtotime("$date-01"); } elseif ($month = array_search($date, $months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) ) { if ($ref && isset($ref['year'])) { // We have a year to glue it to return strtotime("{$ref['year']}-{$months[$month]}-01"); } else return false; // We have the month but don't know anything else } else return strtotime($date); }
php
function ToEpoc($date, $ref = null) { if (preg_match('!^[0-9]{10,}$!', $date)) { // Unix time stamp return $date; } else if (preg_match('!^[0-9]{4}$!', $date)) { // Just year return strtotime("$date-01-01"); } else if (preg_match('!^[0-9]{4}-[0-9]{2}$!', $date)) { // Year + month return strtotime("$date-01"); } elseif ($month = array_search($date, $months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) ) { if ($ref && isset($ref['year'])) { // We have a year to glue it to return strtotime("{$ref['year']}-{$months[$month]}-01"); } else return false; // We have the month but don't know anything else } else return strtotime($date); }
[ "function", "ToEpoc", "(", "$", "date", ",", "$", "ref", "=", "null", ")", "{", "if", "(", "preg_match", "(", "'!^[0-9]{10,}$!'", ",", "$", "date", ")", ")", "{", "// Unix time stamp", "return", "$", "date", ";", "}", "else", "if", "(", "preg_match", "(", "'!^[0-9]{4}$!'", ",", "$", "date", ")", ")", "{", "// Just year", "return", "strtotime", "(", "\"$date-01-01\"", ")", ";", "}", "else", "if", "(", "preg_match", "(", "'!^[0-9]{4}-[0-9]{2}$!'", ",", "$", "date", ")", ")", "{", "// Year + month", "return", "strtotime", "(", "\"$date-01\"", ")", ";", "}", "elseif", "(", "$", "month", "=", "array_search", "(", "$", "date", ",", "$", "months", "=", "array", "(", "'Jan'", ",", "'Feb'", ",", "'Mar'", ",", "'Apr'", ",", "'May'", ",", "'Jun'", ",", "'Jul'", ",", "'Aug'", ",", "'Sep'", ",", "'Oct'", ",", "'Nov'", ",", "'Dec'", ")", ")", ")", "{", "if", "(", "$", "ref", "&&", "isset", "(", "$", "ref", "[", "'year'", "]", ")", ")", "{", "// We have a year to glue it to", "return", "strtotime", "(", "\"{$ref['year']}-{$months[$month]}-01\"", ")", ";", "}", "else", "return", "false", ";", "// We have the month but don't know anything else", "}", "else", "return", "strtotime", "(", "$", "date", ")", ";", "}" ]
Converts an incomming string to an epoc value suitable for use later on @param string $date The raw string to be converted to an epoc @param array|null $ref Optional additional reference information. This is used when the date needs more context e.g. 'Aug' @return int An epoc value
[ "Converts", "an", "incomming", "string", "to", "an", "epoc", "value", "suitable", "for", "use", "later", "on" ]
f53998da9adb36906fdc766c5043ddbe60f2310b
https://github.com/hash-bang/RefLib/blob/f53998da9adb36906fdc766c5043ddbe60f2310b/reflib.php#L353-L367
228,698
mariano/disque-php
src/Connection/Socket.php
Socket.send
public function send($data) { $this->shouldBeConnected(); do { $length = strlen($data); $bytes = fwrite($this->socket, $data); if (empty($bytes)) { throw new ConnectionException("Could not write {$length} bytes to client"); } elseif ($bytes === $length) { break; } $data = substr($data, $bytes); } while ($length > 0); }
php
public function send($data) { $this->shouldBeConnected(); do { $length = strlen($data); $bytes = fwrite($this->socket, $data); if (empty($bytes)) { throw new ConnectionException("Could not write {$length} bytes to client"); } elseif ($bytes === $length) { break; } $data = substr($data, $bytes); } while ($length > 0); }
[ "public", "function", "send", "(", "$", "data", ")", "{", "$", "this", "->", "shouldBeConnected", "(", ")", ";", "do", "{", "$", "length", "=", "strlen", "(", "$", "data", ")", ";", "$", "bytes", "=", "fwrite", "(", "$", "this", "->", "socket", ",", "$", "data", ")", ";", "if", "(", "empty", "(", "$", "bytes", ")", ")", "{", "throw", "new", "ConnectionException", "(", "\"Could not write {$length} bytes to client\"", ")", ";", "}", "elseif", "(", "$", "bytes", "===", "$", "length", ")", "{", "break", ";", "}", "$", "data", "=", "substr", "(", "$", "data", ",", "$", "bytes", ")", ";", "}", "while", "(", "$", "length", ">", "0", ")", ";", "}" ]
Execute a command on the connection @param string $data Data to send @throws ConnectionException
[ "Execute", "a", "command", "on", "the", "connection" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Connection/Socket.php#L114-L129
228,699
mariano/disque-php
src/Connection/Socket.php
Socket.receive
public function receive($keepWaiting = false) { $this->shouldBeConnected(); $type = $this->getType($keepWaiting); if (!array_key_exists($type, $this->responseHandlers)) { throw new ResponseException("Don't know how to handle a response of type {$type}"); } $responseHandlerClass = $this->responseHandlers[$type]; $responseHandler = new $responseHandlerClass($this->getData()); $responseHandler->setReader(function ($bytes) { return fread($this->socket, $bytes); }); $responseHandler->setReceiver(function () use ($keepWaiting) { return $this->receive($keepWaiting); }); $response = $responseHandler->parse(); /** * If Disque returned an error, raise it in form of an exception * @see Disque\Connection\Response\ErrorResponse::parse() */ if ($response instanceof ResponseException) { throw $response; } return $response; }
php
public function receive($keepWaiting = false) { $this->shouldBeConnected(); $type = $this->getType($keepWaiting); if (!array_key_exists($type, $this->responseHandlers)) { throw new ResponseException("Don't know how to handle a response of type {$type}"); } $responseHandlerClass = $this->responseHandlers[$type]; $responseHandler = new $responseHandlerClass($this->getData()); $responseHandler->setReader(function ($bytes) { return fread($this->socket, $bytes); }); $responseHandler->setReceiver(function () use ($keepWaiting) { return $this->receive($keepWaiting); }); $response = $responseHandler->parse(); /** * If Disque returned an error, raise it in form of an exception * @see Disque\Connection\Response\ErrorResponse::parse() */ if ($response instanceof ResponseException) { throw $response; } return $response; }
[ "public", "function", "receive", "(", "$", "keepWaiting", "=", "false", ")", "{", "$", "this", "->", "shouldBeConnected", "(", ")", ";", "$", "type", "=", "$", "this", "->", "getType", "(", "$", "keepWaiting", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "responseHandlers", ")", ")", "{", "throw", "new", "ResponseException", "(", "\"Don't know how to handle a response of type {$type}\"", ")", ";", "}", "$", "responseHandlerClass", "=", "$", "this", "->", "responseHandlers", "[", "$", "type", "]", ";", "$", "responseHandler", "=", "new", "$", "responseHandlerClass", "(", "$", "this", "->", "getData", "(", ")", ")", ";", "$", "responseHandler", "->", "setReader", "(", "function", "(", "$", "bytes", ")", "{", "return", "fread", "(", "$", "this", "->", "socket", ",", "$", "bytes", ")", ";", "}", ")", ";", "$", "responseHandler", "->", "setReceiver", "(", "function", "(", ")", "use", "(", "$", "keepWaiting", ")", "{", "return", "$", "this", "->", "receive", "(", "$", "keepWaiting", ")", ";", "}", ")", ";", "$", "response", "=", "$", "responseHandler", "->", "parse", "(", ")", ";", "/**\n * If Disque returned an error, raise it in form of an exception\n * @see Disque\\Connection\\Response\\ErrorResponse::parse()\n */", "if", "(", "$", "response", "instanceof", "ResponseException", ")", "{", "throw", "$", "response", ";", "}", "return", "$", "response", ";", "}" ]
Read data from connection @param bool $keepWaiting If `true`, timeouts on stream read will be ignored @return mixed Data received @throws ConnectionException @throws ResponseException
[ "Read", "data", "from", "connection" ]
56cf00d97e739fec861717484657dbef2888df60
https://github.com/mariano/disque-php/blob/56cf00d97e739fec861717484657dbef2888df60/src/Connection/Socket.php#L140-L168