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
partition
stringclasses
1 value
sendgrid/sendgrid-php
lib/mail/BccSettings.php
BccSettings.setEmail
public function setEmail($email) { if (!is_string($email) && filter_var($email, FILTER_VALIDATE_EMAIL) ) { throw new TypeException( '$email must valid and be of type string.' ); } $this->email = $email; }
php
public function setEmail($email) { if (!is_string($email) && filter_var($email, FILTER_VALIDATE_EMAIL) ) { throw new TypeException( '$email must valid and be of type string.' ); } $this->email = $email; }
[ "public", "function", "setEmail", "(", "$", "email", ")", "{", "if", "(", "!", "is_string", "(", "$", "email", ")", "&&", "filter_var", "(", "$", "email", ",", "FILTER_VALIDATE_EMAIL", ")", ")", "{", "throw", "new", "TypeException", "(", "'$email must valid and be of type string.'", ")", ";", "}", "$", "this", "->", "email", "=", "$", "email", ";", "}" ]
Add the email setting on a BccSettings object @param string $email The email address that you would like to receive the BCC @throws TypeException
[ "Add", "the", "email", "setting", "on", "a", "BccSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/BccSettings.php#L79-L89
train
sendgrid/sendgrid-php
lib/mail/BccSettings.php
BccSettings.jsonSerialize
public function jsonSerialize() { return array_filter( [ 'enable' => $this->getEnable(), 'email' => $this->getEmail() ], function ($value) { return $value !== null; } ) ?: null; }
php
public function jsonSerialize() { return array_filter( [ 'enable' => $this->getEnable(), 'email' => $this->getEmail() ], function ($value) { return $value !== null; } ) ?: null; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "return", "array_filter", "(", "[", "'enable'", "=>", "$", "this", "->", "getEnable", "(", ")", ",", "'email'", "=>", "$", "this", "->", "getEmail", "(", ")", "]", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", ";", "}", ")", "?", ":", "null", ";", "}" ]
Return an array representing a BccSettings object for the Twilio SendGrid API @return null|array
[ "Return", "an", "array", "representing", "a", "BccSettings", "object", "for", "the", "Twilio", "SendGrid", "API" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/BccSettings.php#L106-L117
train
sendgrid/sendgrid-php
lib/mail/EmailAddress.php
EmailAddress.setEmailAddress
public function setEmailAddress($emailAddress) { if (!(is_string($emailAddress) && filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) ) { throw new TypeException( '$emailAddress must be valid and of type string.' ); } $this->email = $emailAddress; }
php
public function setEmailAddress($emailAddress) { if (!(is_string($emailAddress) && filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) ) { throw new TypeException( '$emailAddress must be valid and of type string.' ); } $this->email = $emailAddress; }
[ "public", "function", "setEmailAddress", "(", "$", "emailAddress", ")", "{", "if", "(", "!", "(", "is_string", "(", "$", "emailAddress", ")", "&&", "filter_var", "(", "$", "emailAddress", ",", "FILTER_VALIDATE_EMAIL", ")", ")", ")", "{", "throw", "new", "TypeException", "(", "'$emailAddress must be valid and of type string.'", ")", ";", "}", "$", "this", "->", "email", "=", "$", "emailAddress", ";", "}" ]
Add the email address to a EmailAddress object @param string $emailAddress The email address @throws TypeException
[ "Add", "the", "email", "address", "to", "a", "EmailAddress", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/EmailAddress.php#L71-L81
train
sendgrid/sendgrid-php
lib/mail/EmailAddress.php
EmailAddress.setName
public function setName($name) { if (!is_string($name)) { throw new TypeException('$name must be of type string.'); } /* Issue #368 ========== If the name is not wrapped in double quotes and contains a comma or semicolon, the API fails to parse it correctly. When wrapped in double quotes, commas, semicolons and unescaped single quotes are supported. Escaped double quotes are supported as well but will appear unescaped in the mail (e.g. "O\'Keefe"). Double quotes will be shown in some email clients, so the name should only be wrapped when necessary. */ // Only wrapp in double quote if comma or semicolon are found if (false !== strpos($name, ',') || false !== strpos($name, ';')) { // Unescape quotes $name = stripslashes(html_entity_decode($name, ENT_QUOTES)); // Escape only double quotes $name = str_replace('"', '\\"', $name); // Wrapp in double quotes $name = '"' . $name . '"'; } $this->name = (!empty($name)) ? $name : null; }
php
public function setName($name) { if (!is_string($name)) { throw new TypeException('$name must be of type string.'); } /* Issue #368 ========== If the name is not wrapped in double quotes and contains a comma or semicolon, the API fails to parse it correctly. When wrapped in double quotes, commas, semicolons and unescaped single quotes are supported. Escaped double quotes are supported as well but will appear unescaped in the mail (e.g. "O\'Keefe"). Double quotes will be shown in some email clients, so the name should only be wrapped when necessary. */ // Only wrapp in double quote if comma or semicolon are found if (false !== strpos($name, ',') || false !== strpos($name, ';')) { // Unescape quotes $name = stripslashes(html_entity_decode($name, ENT_QUOTES)); // Escape only double quotes $name = str_replace('"', '\\"', $name); // Wrapp in double quotes $name = '"' . $name . '"'; } $this->name = (!empty($name)) ? $name : null; }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "{", "throw", "new", "TypeException", "(", "'$name must be of type string.'", ")", ";", "}", "/*\n Issue #368\n ==========\n If the name is not wrapped in double quotes and contains a comma or\n semicolon, the API fails to parse it correctly.\n When wrapped in double quotes, commas, semicolons and unescaped single\n quotes are supported.\n Escaped double quotes are supported as well but will appear unescaped in\n the mail (e.g. \"O\\'Keefe\").\n Double quotes will be shown in some email clients, so the name should\n only be wrapped when necessary.\n */", "// Only wrapp in double quote if comma or semicolon are found", "if", "(", "false", "!==", "strpos", "(", "$", "name", ",", "','", ")", "||", "false", "!==", "strpos", "(", "$", "name", ",", "';'", ")", ")", "{", "// Unescape quotes", "$", "name", "=", "stripslashes", "(", "html_entity_decode", "(", "$", "name", ",", "ENT_QUOTES", ")", ")", ";", "// Escape only double quotes", "$", "name", "=", "str_replace", "(", "'\"'", ",", "'\\\\\"'", ",", "$", "name", ")", ";", "// Wrapp in double quotes", "$", "name", "=", "'\"'", ".", "$", "name", ".", "'\"'", ";", "}", "$", "this", "->", "name", "=", "(", "!", "empty", "(", "$", "name", ")", ")", "?", "$", "name", ":", "null", ";", "}" ]
Add a name to a EmailAddress object @param string $name The name of the person associated with the email @throws TypeException
[ "Add", "a", "name", "to", "a", "EmailAddress", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/EmailAddress.php#L110-L138
train
sendgrid/sendgrid-php
lib/mail/EmailAddress.php
EmailAddress.setSubject
public function setSubject($subject) { if (!is_string($subject)) { throw new TypeException('$subject must be of type string.'); } if (!($subject instanceof Subject)) { $this->subject = new Subject($subject); } else { $this->subject = $subject; } }
php
public function setSubject($subject) { if (!is_string($subject)) { throw new TypeException('$subject must be of type string.'); } if (!($subject instanceof Subject)) { $this->subject = new Subject($subject); } else { $this->subject = $subject; } }
[ "public", "function", "setSubject", "(", "$", "subject", ")", "{", "if", "(", "!", "is_string", "(", "$", "subject", ")", ")", "{", "throw", "new", "TypeException", "(", "'$subject must be of type string.'", ")", ";", "}", "if", "(", "!", "(", "$", "subject", "instanceof", "Subject", ")", ")", "{", "$", "this", "->", "subject", "=", "new", "Subject", "(", "$", "subject", ")", ";", "}", "else", "{", "$", "this", "->", "subject", "=", "$", "subject", ";", "}", "}" ]
Add a subject to a EmailAddress object @param string $subject The personalized subject of the email @throws TypeException
[ "Add", "a", "subject", "to", "a", "EmailAddress", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/EmailAddress.php#L183-L193
train
sendgrid/sendgrid-php
lib/mail/EmailAddress.php
EmailAddress.jsonSerialize
public function jsonSerialize() { return array_filter( [ 'name' => $this->getName(), 'email' => $this->getEmail() ], function ($value) { return $value !== null; } ) ?: null; }
php
public function jsonSerialize() { return array_filter( [ 'name' => $this->getName(), 'email' => $this->getEmail() ], function ($value) { return $value !== null; } ) ?: null; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "return", "array_filter", "(", "[", "'name'", "=>", "$", "this", "->", "getName", "(", ")", ",", "'email'", "=>", "$", "this", "->", "getEmail", "(", ")", "]", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", ";", "}", ")", "?", ":", "null", ";", "}" ]
Return an array representing a EmailAddress object for the Twilio SendGrid API @return null|array
[ "Return", "an", "array", "representing", "a", "EmailAddress", "object", "for", "the", "Twilio", "SendGrid", "API" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/EmailAddress.php#L210-L221
train
sendgrid/sendgrid-php
lib/mail/Personalization.php
Personalization.jsonSerialize
public function jsonSerialize() { if ($this->getHasDynamicTemplate() == true) { $dynamic_substitutions = $this->getSubstitutions(); $substitutions = null; } else { $substitutions = $this->getSubstitutions(); $dynamic_substitutions = null; } return array_filter( [ 'to' => $this->getTos(), 'cc' => $this->getCcs(), 'bcc' => $this->getBccs(), 'subject' => $this->getSubject(), 'headers' => $this->getHeaders(), 'substitutions' => $substitutions, 'dynamic_template_data' => $dynamic_substitutions, 'custom_args' => $this->getCustomArgs(), 'send_at' => $this->getSendAt() ], function ($value) { return $value !== null; } ) ?: null; }
php
public function jsonSerialize() { if ($this->getHasDynamicTemplate() == true) { $dynamic_substitutions = $this->getSubstitutions(); $substitutions = null; } else { $substitutions = $this->getSubstitutions(); $dynamic_substitutions = null; } return array_filter( [ 'to' => $this->getTos(), 'cc' => $this->getCcs(), 'bcc' => $this->getBccs(), 'subject' => $this->getSubject(), 'headers' => $this->getHeaders(), 'substitutions' => $substitutions, 'dynamic_template_data' => $dynamic_substitutions, 'custom_args' => $this->getCustomArgs(), 'send_at' => $this->getSendAt() ], function ($value) { return $value !== null; } ) ?: null; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "if", "(", "$", "this", "->", "getHasDynamicTemplate", "(", ")", "==", "true", ")", "{", "$", "dynamic_substitutions", "=", "$", "this", "->", "getSubstitutions", "(", ")", ";", "$", "substitutions", "=", "null", ";", "}", "else", "{", "$", "substitutions", "=", "$", "this", "->", "getSubstitutions", "(", ")", ";", "$", "dynamic_substitutions", "=", "null", ";", "}", "return", "array_filter", "(", "[", "'to'", "=>", "$", "this", "->", "getTos", "(", ")", ",", "'cc'", "=>", "$", "this", "->", "getCcs", "(", ")", ",", "'bcc'", "=>", "$", "this", "->", "getBccs", "(", ")", ",", "'subject'", "=>", "$", "this", "->", "getSubject", "(", ")", ",", "'headers'", "=>", "$", "this", "->", "getHeaders", "(", ")", ",", "'substitutions'", "=>", "$", "substitutions", ",", "'dynamic_template_data'", "=>", "$", "dynamic_substitutions", ",", "'custom_args'", "=>", "$", "this", "->", "getCustomArgs", "(", ")", ",", "'send_at'", "=>", "$", "this", "->", "getSendAt", "(", ")", "]", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", ";", "}", ")", "?", ":", "null", ";", "}" ]
Return an array representing a Personalization object for the Twilio SendGrid API @return null|array
[ "Return", "an", "array", "representing", "a", "Personalization", "object", "for", "the", "Twilio", "SendGrid", "API" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Personalization.php#L285-L311
train
sendgrid/sendgrid-php
lib/contacts/Recipient.php
Recipient.jsonSerialize
public function jsonSerialize() { return array_filter( [ 'email' => $this->getEmail(), 'first_name' => $this->getFirstName(), 'last_name' => $this->getLastName() ], function ($value) { return $value !== null; } ) ?: null; }
php
public function jsonSerialize() { return array_filter( [ 'email' => $this->getEmail(), 'first_name' => $this->getFirstName(), 'last_name' => $this->getLastName() ], function ($value) { return $value !== null; } ) ?: null; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "return", "array_filter", "(", "[", "'email'", "=>", "$", "this", "->", "getEmail", "(", ")", ",", "'first_name'", "=>", "$", "this", "->", "getFirstName", "(", ")", ",", "'last_name'", "=>", "$", "this", "->", "getLastName", "(", ")", "]", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", ";", "}", ")", "?", ":", "null", ";", "}" ]
Return an array representing a recipient object for the Twilio SendGrid API @return null|array
[ "Return", "an", "array", "representing", "a", "recipient", "object", "for", "the", "Twilio", "SendGrid", "API" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/contacts/Recipient.php#L79-L91
train
sendgrid/sendgrid-php
lib/stats/Stats.php
Stats.getCategory
public function getCategory($categories) { $this->validateNumericArray('categories', $categories); $stats = $this->getGlobal(); $stats['categories'] = $categories; return $stats; }
php
public function getCategory($categories) { $this->validateNumericArray('categories', $categories); $stats = $this->getGlobal(); $stats['categories'] = $categories; return $stats; }
[ "public", "function", "getCategory", "(", "$", "categories", ")", "{", "$", "this", "->", "validateNumericArray", "(", "'categories'", ",", "$", "categories", ")", ";", "$", "stats", "=", "$", "this", "->", "getGlobal", "(", ")", ";", "$", "stats", "[", "'categories'", "]", "=", "$", "categories", ";", "return", "$", "stats", ";", "}" ]
Retrieve an array of categories @param array $categories @return array @throws \Exception
[ "Retrieve", "an", "array", "of", "categories" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/stats/Stats.php#L84-L90
train
sendgrid/sendgrid-php
lib/stats/Stats.php
Stats.getSubuser
public function getSubuser($subusers) { $this->validateNumericArray('subusers', $subusers); $stats = $this->getGlobal(); $stats['subusers'] = $subusers; return $stats; }
php
public function getSubuser($subusers) { $this->validateNumericArray('subusers', $subusers); $stats = $this->getGlobal(); $stats['subusers'] = $subusers; return $stats; }
[ "public", "function", "getSubuser", "(", "$", "subusers", ")", "{", "$", "this", "->", "validateNumericArray", "(", "'subusers'", ",", "$", "subusers", ")", ";", "$", "stats", "=", "$", "this", "->", "getGlobal", "(", ")", ";", "$", "stats", "[", "'subusers'", "]", "=", "$", "subusers", ";", "return", "$", "stats", ";", "}" ]
Retrieve global stats parameters, start date, end date and aggregated for the given set of subusers @param array $subusers Subuser accounts @return array @throws \Exception
[ "Retrieve", "global", "stats", "parameters", "start", "date", "end", "date", "and", "aggregated", "for", "the", "given", "set", "of", "subusers" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/stats/Stats.php#L101-L107
train
sendgrid/sendgrid-php
lib/stats/Stats.php
Stats.getSum
public function getSum( $sortByMetric = 'delivered', $sortByDirection = 'desc', $limit = 5, $offset = 0 ) { $this->validateOptions( 'sortByDirection', $sortByDirection, self::OPTIONS_SORT_DIRECTION ); $this->validateInteger('limit', $limit); $this->validateInteger('offset', $offset); $stats = $this->getGlobal(); $stats['sort_by_metric'] = $sortByMetric; $stats['sort_by_direction'] = $sortByDirection; $stats['limit'] = $limit; $stats['offset'] = $offset; return $stats; }
php
public function getSum( $sortByMetric = 'delivered', $sortByDirection = 'desc', $limit = 5, $offset = 0 ) { $this->validateOptions( 'sortByDirection', $sortByDirection, self::OPTIONS_SORT_DIRECTION ); $this->validateInteger('limit', $limit); $this->validateInteger('offset', $offset); $stats = $this->getGlobal(); $stats['sort_by_metric'] = $sortByMetric; $stats['sort_by_direction'] = $sortByDirection; $stats['limit'] = $limit; $stats['offset'] = $offset; return $stats; }
[ "public", "function", "getSum", "(", "$", "sortByMetric", "=", "'delivered'", ",", "$", "sortByDirection", "=", "'desc'", ",", "$", "limit", "=", "5", ",", "$", "offset", "=", "0", ")", "{", "$", "this", "->", "validateOptions", "(", "'sortByDirection'", ",", "$", "sortByDirection", ",", "self", "::", "OPTIONS_SORT_DIRECTION", ")", ";", "$", "this", "->", "validateInteger", "(", "'limit'", ",", "$", "limit", ")", ";", "$", "this", "->", "validateInteger", "(", "'offset'", ",", "$", "offset", ")", ";", "$", "stats", "=", "$", "this", "->", "getGlobal", "(", ")", ";", "$", "stats", "[", "'sort_by_metric'", "]", "=", "$", "sortByMetric", ";", "$", "stats", "[", "'sort_by_direction'", "]", "=", "$", "sortByDirection", ";", "$", "stats", "[", "'limit'", "]", "=", "$", "limit", ";", "$", "stats", "[", "'offset'", "]", "=", "$", "offset", ";", "return", "$", "stats", ";", "}" ]
Retrieve global stats parameters, start date, end date, aggregated by, sort by metric, sort by direction, limit and offset @param string $sortByMetric blocks|bounce_drops|bounces| clicks|deferred|delivered| invalid_emails|opens|processed| requests|spam_report_drops| spam_reports|unique_clicks| unique_opens|unsubscribe_drops| unsubsribes @param string $sortByDirection asc|desc @param integer $limit The number of results to return @param integer $offset The point in the list to begin retrieving results @return array @throws \Exception
[ "Retrieve", "global", "stats", "parameters", "start", "date", "end", "date", "aggregated", "by", "sort", "by", "metric", "sort", "by", "direction", "limit", "and", "offset" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/stats/Stats.php#L129-L147
train
sendgrid/sendgrid-php
lib/stats/Stats.php
Stats.getSubuserMonthly
public function getSubuserMonthly( $subuser = null, $sortByMetric = 'delivered', $sortByDirection = 'desc', $limit = 5, $offset = 0 ) { $this->validateOptions( 'sortByDirection', $sortByDirection, self::OPTIONS_SORT_DIRECTION ); $this->validateInteger('limit', $limit); $this->validateInteger('offset', $offset); return [ 'date' => $this->startDate, 'subuser' => $subuser, 'sort_by_metric' => $sortByMetric, 'sort_by_direction' => $sortByDirection, 'limit' => $limit, 'offset' => $offset ]; }
php
public function getSubuserMonthly( $subuser = null, $sortByMetric = 'delivered', $sortByDirection = 'desc', $limit = 5, $offset = 0 ) { $this->validateOptions( 'sortByDirection', $sortByDirection, self::OPTIONS_SORT_DIRECTION ); $this->validateInteger('limit', $limit); $this->validateInteger('offset', $offset); return [ 'date' => $this->startDate, 'subuser' => $subuser, 'sort_by_metric' => $sortByMetric, 'sort_by_direction' => $sortByDirection, 'limit' => $limit, 'offset' => $offset ]; }
[ "public", "function", "getSubuserMonthly", "(", "$", "subuser", "=", "null", ",", "$", "sortByMetric", "=", "'delivered'", ",", "$", "sortByDirection", "=", "'desc'", ",", "$", "limit", "=", "5", ",", "$", "offset", "=", "0", ")", "{", "$", "this", "->", "validateOptions", "(", "'sortByDirection'", ",", "$", "sortByDirection", ",", "self", "::", "OPTIONS_SORT_DIRECTION", ")", ";", "$", "this", "->", "validateInteger", "(", "'limit'", ",", "$", "limit", ")", ";", "$", "this", "->", "validateInteger", "(", "'offset'", ",", "$", "offset", ")", ";", "return", "[", "'date'", "=>", "$", "this", "->", "startDate", ",", "'subuser'", "=>", "$", "subuser", ",", "'sort_by_metric'", "=>", "$", "sortByMetric", ",", "'sort_by_direction'", "=>", "$", "sortByDirection", ",", "'limit'", "=>", "$", "limit", ",", "'offset'", "=>", "$", "offset", "]", ";", "}" ]
Retrieve monthly stats by subuser @param string $subuser Subuser account @param string $sortByMetric blocks|bounce_drops|bounces| clicks|deferred|delivered| invalid_emails|opens|processed| requests|spam_report_drops| spam_reports|unique_clicks| unique_opens|unsubscribe_drops| unsubsribes @param string $sortByDirection asc|desc @param integer $limit The number of results to return @param integer $offset The point in the list to begin retrieving results @return array @throws \Exception
[ "Retrieve", "monthly", "stats", "by", "subuser" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/stats/Stats.php#L168-L190
train
sendgrid/sendgrid-php
lib/stats/Stats.php
Stats.validateNumericArray
protected function validateNumericArray($name, $value) { if (!is_array($value) || empty($value) || !$this->isNumeric($value)) { throw new \Exception($name . ' must be a non-empty numeric array.'); } }
php
protected function validateNumericArray($name, $value) { if (!is_array($value) || empty($value) || !$this->isNumeric($value)) { throw new \Exception($name . ' must be a non-empty numeric array.'); } }
[ "protected", "function", "validateNumericArray", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", "||", "empty", "(", "$", "value", ")", "||", "!", "$", "this", "->", "isNumeric", "(", "$", "value", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "name", ".", "' must be a non-empty numeric array.'", ")", ";", "}", "}" ]
Validate a numeric array @param string $name Name as a string @param array $value Value as an array of integers @return null @throws \Exception
[ "Validate", "a", "numeric", "array" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/stats/Stats.php#L251-L256
train
sendgrid/sendgrid-php
lib/mail/OpenTracking.php
OpenTracking.jsonSerialize
public function jsonSerialize() { return array_filter( [ 'enable' => $this->getEnable(), 'substitution_tag' => $this->getSubstitutionTag() ], function ($value) { return $value !== null; } ) ?: null; }
php
public function jsonSerialize() { return array_filter( [ 'enable' => $this->getEnable(), 'substitution_tag' => $this->getSubstitutionTag() ], function ($value) { return $value !== null; } ) ?: null; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "return", "array_filter", "(", "[", "'enable'", "=>", "$", "this", "->", "getEnable", "(", ")", ",", "'substitution_tag'", "=>", "$", "this", "->", "getSubstitutionTag", "(", ")", "]", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", ";", "}", ")", "?", ":", "null", ";", "}" ]
Return an array representing a OpenTracking object for the Twilio SendGrid API @return null|array
[ "Return", "an", "array", "representing", "a", "OpenTracking", "object", "for", "the", "Twilio", "SendGrid", "API" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/OpenTracking.php#L112-L123
train
sendgrid/sendgrid-php
lib/mail/MailSettings.php
MailSettings.setBccSettings
public function setBccSettings($enable, $email = null) { if ($enable instanceof BccSettings) { $bcc = $enable; $this->bcc = $bcc; return; } if (!is_bool($enable)) { throw new TypeException( '$enable must be an instance of SendGrid\Mail\BccSettings or of type bool.' ); } $this->bcc = new BccSettings($enable, $email); }
php
public function setBccSettings($enable, $email = null) { if ($enable instanceof BccSettings) { $bcc = $enable; $this->bcc = $bcc; return; } if (!is_bool($enable)) { throw new TypeException( '$enable must be an instance of SendGrid\Mail\BccSettings or of type bool.' ); } $this->bcc = new BccSettings($enable, $email); }
[ "public", "function", "setBccSettings", "(", "$", "enable", ",", "$", "email", "=", "null", ")", "{", "if", "(", "$", "enable", "instanceof", "BccSettings", ")", "{", "$", "bcc", "=", "$", "enable", ";", "$", "this", "->", "bcc", "=", "$", "bcc", ";", "return", ";", "}", "if", "(", "!", "is_bool", "(", "$", "enable", ")", ")", "{", "throw", "new", "TypeException", "(", "'$enable must be an instance of SendGrid\\Mail\\BccSettings or of type bool.'", ")", ";", "}", "$", "this", "->", "bcc", "=", "new", "BccSettings", "(", "$", "enable", ",", "$", "email", ")", ";", "}" ]
Set the bcc settings on a MailSettings object @param BccSettings|bool $enable The BccSettings object or an indication if the setting is enabled @param string|null $email The email address that you would like to receive the BCC @throws TypeException
[ "Set", "the", "bcc", "settings", "on", "a", "MailSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/MailSettings.php#L82-L95
train
sendgrid/sendgrid-php
lib/mail/MailSettings.php
MailSettings.setBypassListManagement
public function setBypassListManagement($enable) { if ($enable instanceof BypassListManagement) { $bypass_list_management = $enable; $this->bypass_list_management = $bypass_list_management; return; } if (!is_bool($enable)) { throw new TypeException( '$enable must be an instance of SendGrid\Mail\BypassListManagement or of type bool.' ); } $this->bypass_list_management = new BypassListManagement($enable); return; }
php
public function setBypassListManagement($enable) { if ($enable instanceof BypassListManagement) { $bypass_list_management = $enable; $this->bypass_list_management = $bypass_list_management; return; } if (!is_bool($enable)) { throw new TypeException( '$enable must be an instance of SendGrid\Mail\BypassListManagement or of type bool.' ); } $this->bypass_list_management = new BypassListManagement($enable); return; }
[ "public", "function", "setBypassListManagement", "(", "$", "enable", ")", "{", "if", "(", "$", "enable", "instanceof", "BypassListManagement", ")", "{", "$", "bypass_list_management", "=", "$", "enable", ";", "$", "this", "->", "bypass_list_management", "=", "$", "bypass_list_management", ";", "return", ";", "}", "if", "(", "!", "is_bool", "(", "$", "enable", ")", ")", "{", "throw", "new", "TypeException", "(", "'$enable must be an instance of SendGrid\\Mail\\BypassListManagement or of type bool.'", ")", ";", "}", "$", "this", "->", "bypass_list_management", "=", "new", "BypassListManagement", "(", "$", "enable", ")", ";", "return", ";", "}" ]
Set bypass list management settings on a MailSettings object @param BypassListManagement|bool $enable The BypassListManagement object or an indication if the setting is enabled @throws TypeException
[ "Set", "bypass", "list", "management", "settings", "on", "a", "MailSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/MailSettings.php#L116-L130
train
sendgrid/sendgrid-php
lib/mail/MailSettings.php
MailSettings.setFooter
public function setFooter($enable, $text = null, $html = null) { if ($enable instanceof Footer) { $footer = $enable; $this->footer = $footer; return; } $this->footer = new Footer($enable, $text, $html); return; }
php
public function setFooter($enable, $text = null, $html = null) { if ($enable instanceof Footer) { $footer = $enable; $this->footer = $footer; return; } $this->footer = new Footer($enable, $text, $html); return; }
[ "public", "function", "setFooter", "(", "$", "enable", ",", "$", "text", "=", "null", ",", "$", "html", "=", "null", ")", "{", "if", "(", "$", "enable", "instanceof", "Footer", ")", "{", "$", "footer", "=", "$", "enable", ";", "$", "this", "->", "footer", "=", "$", "footer", ";", "return", ";", "}", "$", "this", "->", "footer", "=", "new", "Footer", "(", "$", "enable", ",", "$", "text", ",", "$", "html", ")", ";", "return", ";", "}" ]
Set the footer settings on a MailSettings object @param Footer|bool $enable The Footer object or an indication if the setting is enabled @param string|null $text The plain text content of your footer @param string|null $html The HTML content of your footer @return null
[ "Set", "the", "footer", "settings", "on", "a", "MailSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/MailSettings.php#L152-L161
train
sendgrid/sendgrid-php
lib/mail/MailSettings.php
MailSettings.setSandboxMode
public function setSandboxMode($enable) { if ($enable instanceof SandBoxMode) { $sandbox_mode = $enable; $this->sandbox_mode = $sandbox_mode; return; } $this->sandbox_mode = new SandBoxMode($enable); return; }
php
public function setSandboxMode($enable) { if ($enable instanceof SandBoxMode) { $sandbox_mode = $enable; $this->sandbox_mode = $sandbox_mode; return; } $this->sandbox_mode = new SandBoxMode($enable); return; }
[ "public", "function", "setSandboxMode", "(", "$", "enable", ")", "{", "if", "(", "$", "enable", "instanceof", "SandBoxMode", ")", "{", "$", "sandbox_mode", "=", "$", "enable", ";", "$", "this", "->", "sandbox_mode", "=", "$", "sandbox_mode", ";", "return", ";", "}", "$", "this", "->", "sandbox_mode", "=", "new", "SandBoxMode", "(", "$", "enable", ")", ";", "return", ";", "}" ]
Set sandbox mode settings on a MailSettings object @param SandBoxMode|bool $enable The SandBoxMode object or an indication if the setting is enabled @return null
[ "Set", "sandbox", "mode", "settings", "on", "a", "MailSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/MailSettings.php#L181-L190
train
sendgrid/sendgrid-php
lib/mail/MailSettings.php
MailSettings.setSpamCheck
public function setSpamCheck($enable, $threshold = null, $post_to_url = null) { if ($enable instanceof SpamCheck) { $spam_check = $enable; $this->spam_check = $spam_check; return; } $this->spam_check = new SpamCheck($enable, $threshold, $post_to_url); return; }
php
public function setSpamCheck($enable, $threshold = null, $post_to_url = null) { if ($enable instanceof SpamCheck) { $spam_check = $enable; $this->spam_check = $spam_check; return; } $this->spam_check = new SpamCheck($enable, $threshold, $post_to_url); return; }
[ "public", "function", "setSpamCheck", "(", "$", "enable", ",", "$", "threshold", "=", "null", ",", "$", "post_to_url", "=", "null", ")", "{", "if", "(", "$", "enable", "instanceof", "SpamCheck", ")", "{", "$", "spam_check", "=", "$", "enable", ";", "$", "this", "->", "spam_check", "=", "$", "spam_check", ";", "return", ";", "}", "$", "this", "->", "spam_check", "=", "new", "SpamCheck", "(", "$", "enable", ",", "$", "threshold", ",", "$", "post_to_url", ")", ";", "return", ";", "}" ]
Set spam check settings on a MailSettings object @param SpamCheck|bool $enable The SpamCheck object or an indication if the setting is enabled @param int $threshold The threshold used to determine if your content qualifies as spam on a scale from 1 to 10, with 10 being most strict, or most @param string $post_to_url An Inbound Parse URL that you would like a copy of your email along with the spam report to be sent to @return null
[ "Set", "spam", "check", "settings", "on", "a", "MailSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/MailSettings.php#L233-L242
train
sendgrid/sendgrid-php
lib/mail/MailSettings.php
MailSettings.jsonSerialize
public function jsonSerialize() { return array_filter( [ 'bcc' => $this->getBccSettings(), 'bypass_list_management' => $this->getBypassListManagement(), 'footer' => $this->getFooter(), 'sandbox_mode' => $this->getSandboxMode(), 'spam_check' => $this->getSpamCheck() ], function ($value) { return $value !== null; } ) ?: null; }
php
public function jsonSerialize() { return array_filter( [ 'bcc' => $this->getBccSettings(), 'bypass_list_management' => $this->getBypassListManagement(), 'footer' => $this->getFooter(), 'sandbox_mode' => $this->getSandboxMode(), 'spam_check' => $this->getSpamCheck() ], function ($value) { return $value !== null; } ) ?: null; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "return", "array_filter", "(", "[", "'bcc'", "=>", "$", "this", "->", "getBccSettings", "(", ")", ",", "'bypass_list_management'", "=>", "$", "this", "->", "getBypassListManagement", "(", ")", ",", "'footer'", "=>", "$", "this", "->", "getFooter", "(", ")", ",", "'sandbox_mode'", "=>", "$", "this", "->", "getSandboxMode", "(", ")", ",", "'spam_check'", "=>", "$", "this", "->", "getSpamCheck", "(", ")", "]", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", ";", "}", ")", "?", ":", "null", ";", "}" ]
Return an array representing a MailSettings object for the Twilio SendGrid API @return null|array
[ "Return", "an", "array", "representing", "a", "MailSettings", "object", "for", "the", "Twilio", "SendGrid", "API" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/MailSettings.php#L259-L273
train
sendgrid/sendgrid-php
lib/mail/Substitution.php
Substitution.setValue
public function setValue($value) { if (!is_string($value) && !is_array($value) && !is_object($value) &&!is_bool($value) &&!is_int($value)) { throw new TypeException('$value must be of type string, array or object.'); } $this->value = $value; }
php
public function setValue($value) { if (!is_string($value) && !is_array($value) && !is_object($value) &&!is_bool($value) &&!is_int($value)) { throw new TypeException('$value must be of type string, array or object.'); } $this->value = $value; }
[ "public", "function", "setValue", "(", "$", "value", ")", "{", "if", "(", "!", "is_string", "(", "$", "value", ")", "&&", "!", "is_array", "(", "$", "value", ")", "&&", "!", "is_object", "(", "$", "value", ")", "&&", "!", "is_bool", "(", "$", "value", ")", "&&", "!", "is_int", "(", "$", "value", ")", ")", "{", "throw", "new", "TypeException", "(", "'$value must be of type string, array or object.'", ")", ";", "}", "$", "this", "->", "value", "=", "$", "value", ";", "}" ]
Add the value on a Substitution object @param string|array|bool|int $value Substitution value @throws TypeException @return null
[ "Add", "the", "value", "on", "a", "Substitution", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Substitution.php#L85-L91
train
sendgrid/sendgrid-php
lib/mail/Content.php
Content.jsonSerialize
public function jsonSerialize() { return array_filter( [ 'type' => $this->getType(), 'value' => $this->getValue() ], function ($value) { return $value !== null; } ) ?: null; }
php
public function jsonSerialize() { return array_filter( [ 'type' => $this->getType(), 'value' => $this->getValue() ], function ($value) { return $value !== null; } ) ?: null; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "return", "array_filter", "(", "[", "'type'", "=>", "$", "this", "->", "getType", "(", ")", ",", "'value'", "=>", "$", "this", "->", "getValue", "(", ")", "]", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", ";", "}", ")", "?", ":", "null", ";", "}" ]
Return an array representing a Contact object for the Twilio SendGrid API @return null|array
[ "Return", "an", "array", "representing", "a", "Contact", "object", "for", "the", "Twilio", "SendGrid", "API" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Content.php#L106-L117
train
sendgrid/sendgrid-php
lib/mail/GroupsToDisplay.php
GroupsToDisplay.setGroupsToDisplay
public function setGroupsToDisplay($groups_to_display) { if (!is_array($groups_to_display)) { throw new TypeException('$groups_to_display must be an array.'); } if (is_array($groups_to_display)) { $this->groups_to_display = $groups_to_display; } else { $this->groups_to_display[] = $groups_to_display; } }
php
public function setGroupsToDisplay($groups_to_display) { if (!is_array($groups_to_display)) { throw new TypeException('$groups_to_display must be an array.'); } if (is_array($groups_to_display)) { $this->groups_to_display = $groups_to_display; } else { $this->groups_to_display[] = $groups_to_display; } }
[ "public", "function", "setGroupsToDisplay", "(", "$", "groups_to_display", ")", "{", "if", "(", "!", "is_array", "(", "$", "groups_to_display", ")", ")", "{", "throw", "new", "TypeException", "(", "'$groups_to_display must be an array.'", ")", ";", "}", "if", "(", "is_array", "(", "$", "groups_to_display", ")", ")", "{", "$", "this", "->", "groups_to_display", "=", "$", "groups_to_display", ";", "}", "else", "{", "$", "this", "->", "groups_to_display", "[", "]", "=", "$", "groups_to_display", ";", "}", "}" ]
Add a group to display on a GroupsToDisplay object @param int|int[] $groups_to_display The unsubscribe group(s) that you would like to be displayed on the unsubscribe preferences page @throws TypeException @return null
[ "Add", "a", "group", "to", "display", "on", "a", "GroupsToDisplay", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/GroupsToDisplay.php#L56-L66
train
sendgrid/sendgrid-php
lib/mail/Attachment.php
Attachment.setContent
public function setContent($content) { if (!is_string($content)) { throw new TypeException('$content must be of type string.'); } if (!$this->isBase64($content)) { $this->content = base64_encode($content); } else { $this->content = $content; } }
php
public function setContent($content) { if (!is_string($content)) { throw new TypeException('$content must be of type string.'); } if (!$this->isBase64($content)) { $this->content = base64_encode($content); } else { $this->content = $content; } }
[ "public", "function", "setContent", "(", "$", "content", ")", "{", "if", "(", "!", "is_string", "(", "$", "content", ")", ")", "{", "throw", "new", "TypeException", "(", "'$content must be of type string.'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isBase64", "(", "$", "content", ")", ")", "{", "$", "this", "->", "content", "=", "base64_encode", "(", "$", "content", ")", ";", "}", "else", "{", "$", "this", "->", "content", "=", "$", "content", ";", "}", "}" ]
Add the content to a Attachment object @param string $content Base64 encoded content @throws TypeException
[ "Add", "the", "content", "to", "a", "Attachment", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Attachment.php#L77-L87
train
sendgrid/sendgrid-php
lib/mail/Attachment.php
Attachment.isBase64
private function isBase64($string) { $decoded_data = base64_decode($string, true); $encoded_data = base64_encode($decoded_data); if ($encoded_data != $string) { return false; } return true; }
php
private function isBase64($string) { $decoded_data = base64_decode($string, true); $encoded_data = base64_encode($decoded_data); if ($encoded_data != $string) { return false; } return true; }
[ "private", "function", "isBase64", "(", "$", "string", ")", "{", "$", "decoded_data", "=", "base64_decode", "(", "$", "string", ",", "true", ")", ";", "$", "encoded_data", "=", "base64_encode", "(", "$", "decoded_data", ")", ";", "if", "(", "$", "encoded_data", "!=", "$", "string", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Verifies whether or not the provided string is a valid base64 string @param $string string The string that has to be checked @return bool
[ "Verifies", "whether", "or", "not", "the", "provided", "string", "is", "a", "valid", "base64", "string" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Attachment.php#L205-L213
train
sendgrid/sendgrid-php
lib/mail/Asm.php
Asm.setGroupId
public function setGroupId($group_id) { if ($group_id instanceof GroupId) { $this->group_id = $group_id->getGroupId(); } else { if (!is_int($group_id)) { throw new TypeException( '$group_id must be an instance of Twilio SendGrid\Mail\GroupId or of type int.' ); } $this->group_id = new GroupId($group_id); } return; }
php
public function setGroupId($group_id) { if ($group_id instanceof GroupId) { $this->group_id = $group_id->getGroupId(); } else { if (!is_int($group_id)) { throw new TypeException( '$group_id must be an instance of Twilio SendGrid\Mail\GroupId or of type int.' ); } $this->group_id = new GroupId($group_id); } return; }
[ "public", "function", "setGroupId", "(", "$", "group_id", ")", "{", "if", "(", "$", "group_id", "instanceof", "GroupId", ")", "{", "$", "this", "->", "group_id", "=", "$", "group_id", "->", "getGroupId", "(", ")", ";", "}", "else", "{", "if", "(", "!", "is_int", "(", "$", "group_id", ")", ")", "{", "throw", "new", "TypeException", "(", "'$group_id must be an instance of Twilio SendGrid\\Mail\\GroupId or of type int.'", ")", ";", "}", "$", "this", "->", "group_id", "=", "new", "GroupId", "(", "$", "group_id", ")", ";", "}", "return", ";", "}" ]
Add the group id to a Asm object @param int|GroupId $group_id The unsubscribe group to associate with this email @throws TypeException
[ "Add", "the", "group", "id", "to", "a", "Asm", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Asm.php#L67-L80
train
sendgrid/sendgrid-php
lib/mail/Asm.php
Asm.jsonSerialize
public function jsonSerialize() { return array_filter( [ 'group_id' => $this->getGroupId(), 'groups_to_display' => $this->getGroupsToDisplay() ], function ($value) { return $value !== null; } ) ?: null; }
php
public function jsonSerialize() { return array_filter( [ 'group_id' => $this->getGroupId(), 'groups_to_display' => $this->getGroupsToDisplay() ], function ($value) { return $value !== null; } ) ?: null; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "return", "array_filter", "(", "[", "'group_id'", "=>", "$", "this", "->", "getGroupId", "(", ")", ",", "'groups_to_display'", "=>", "$", "this", "->", "getGroupsToDisplay", "(", ")", "]", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", ";", "}", ")", "?", ":", "null", ";", "}" ]
Return an array representing a Asm object for the Twilio SendGrid API @return null|array
[ "Return", "an", "array", "representing", "a", "Asm", "object", "for", "the", "Twilio", "SendGrid", "API" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Asm.php#L138-L149
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addRecipientEmail
private function addRecipientEmail( $emailType, $email, $name = null, $substitutions = null, $personalizationIndex = null, $personalization = null ) { $personalizationFunctionCall = "add" . $emailType; $emailType = "\SendGrid\Mail\\" . $emailType; if (!($email instanceof $emailType)) { $email = new $emailType( $email, $name, $substitutions ); } if ($personalization != null) { $personalization->$personalizationFunctionCall($email); if ($subs = $email->getSubstitutions()) { foreach ($subs as $key => $value) { $personalization->addSubstitution($key, $value); } } $this->addPersonalization($personalization); return; } else { if (isset($personalizationIndex) && !isset($this->personalization[$personalizationIndex]) ) { // TODO: We should only do this if there exists an index // previous. For example, if given an index 3 and there is // no index 2, we should throw an error. $this->personalization[$personalizationIndex] = new Personalization(); } if ($this->personalization[0] != null && $personalizationIndex == 0) { $this->personalization[0]->$personalizationFunctionCall($email); if ($subs = $email->getSubstitutions()) { foreach ($subs as $key => $value) { $this->personalization[0]->addSubstitution($key, $value); } } return; } else if ($this->personalization[$personalizationIndex] != null) { $this->personalization[$personalizationIndex]->$personalizationFunctionCall($email); if ($subs = $email->getSubstitutions()) { foreach ($subs as $key => $value) { $this->personalization[$personalizationIndex]->addSubstitution( $key, $value ); } } return; } else { $personalization = new Personalization(); $personalization->$personalizationFunctionCall($email); if ($subs = $email->getSubstitutions()) { foreach ($subs as $key => $value) { $personalization->addSubstitution($key, $value); } } if (($personalizationIndex != 0) && ($this->getPersonalizationCount() <= $personalizationIndex) ) { $this->personalization[$personalizationIndex] = $personalization; } else { $this->addPersonalization($personalization); } return; } } }
php
private function addRecipientEmail( $emailType, $email, $name = null, $substitutions = null, $personalizationIndex = null, $personalization = null ) { $personalizationFunctionCall = "add" . $emailType; $emailType = "\SendGrid\Mail\\" . $emailType; if (!($email instanceof $emailType)) { $email = new $emailType( $email, $name, $substitutions ); } if ($personalization != null) { $personalization->$personalizationFunctionCall($email); if ($subs = $email->getSubstitutions()) { foreach ($subs as $key => $value) { $personalization->addSubstitution($key, $value); } } $this->addPersonalization($personalization); return; } else { if (isset($personalizationIndex) && !isset($this->personalization[$personalizationIndex]) ) { // TODO: We should only do this if there exists an index // previous. For example, if given an index 3 and there is // no index 2, we should throw an error. $this->personalization[$personalizationIndex] = new Personalization(); } if ($this->personalization[0] != null && $personalizationIndex == 0) { $this->personalization[0]->$personalizationFunctionCall($email); if ($subs = $email->getSubstitutions()) { foreach ($subs as $key => $value) { $this->personalization[0]->addSubstitution($key, $value); } } return; } else if ($this->personalization[$personalizationIndex] != null) { $this->personalization[$personalizationIndex]->$personalizationFunctionCall($email); if ($subs = $email->getSubstitutions()) { foreach ($subs as $key => $value) { $this->personalization[$personalizationIndex]->addSubstitution( $key, $value ); } } return; } else { $personalization = new Personalization(); $personalization->$personalizationFunctionCall($email); if ($subs = $email->getSubstitutions()) { foreach ($subs as $key => $value) { $personalization->addSubstitution($key, $value); } } if (($personalizationIndex != 0) && ($this->getPersonalizationCount() <= $personalizationIndex) ) { $this->personalization[$personalizationIndex] = $personalization; } else { $this->addPersonalization($personalization); } return; } } }
[ "private", "function", "addRecipientEmail", "(", "$", "emailType", ",", "$", "email", ",", "$", "name", "=", "null", ",", "$", "substitutions", "=", "null", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "$", "personalizationFunctionCall", "=", "\"add\"", ".", "$", "emailType", ";", "$", "emailType", "=", "\"\\SendGrid\\Mail\\\\\"", ".", "$", "emailType", ";", "if", "(", "!", "(", "$", "email", "instanceof", "$", "emailType", ")", ")", "{", "$", "email", "=", "new", "$", "emailType", "(", "$", "email", ",", "$", "name", ",", "$", "substitutions", ")", ";", "}", "if", "(", "$", "personalization", "!=", "null", ")", "{", "$", "personalization", "->", "$", "personalizationFunctionCall", "(", "$", "email", ")", ";", "if", "(", "$", "subs", "=", "$", "email", "->", "getSubstitutions", "(", ")", ")", "{", "foreach", "(", "$", "subs", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "personalization", "->", "addSubstitution", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "$", "this", "->", "addPersonalization", "(", "$", "personalization", ")", ";", "return", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "personalizationIndex", ")", "&&", "!", "isset", "(", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", ")", ")", "{", "// TODO: We should only do this if there exists an index", "// previous. For example, if given an index 3 and there is", "// no index 2, we should throw an error.", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "=", "new", "Personalization", "(", ")", ";", "}", "if", "(", "$", "this", "->", "personalization", "[", "0", "]", "!=", "null", "&&", "$", "personalizationIndex", "==", "0", ")", "{", "$", "this", "->", "personalization", "[", "0", "]", "->", "$", "personalizationFunctionCall", "(", "$", "email", ")", ";", "if", "(", "$", "subs", "=", "$", "email", "->", "getSubstitutions", "(", ")", ")", "{", "foreach", "(", "$", "subs", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "personalization", "[", "0", "]", "->", "addSubstitution", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "return", ";", "}", "else", "if", "(", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "!=", "null", ")", "{", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "->", "$", "personalizationFunctionCall", "(", "$", "email", ")", ";", "if", "(", "$", "subs", "=", "$", "email", "->", "getSubstitutions", "(", ")", ")", "{", "foreach", "(", "$", "subs", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "->", "addSubstitution", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "return", ";", "}", "else", "{", "$", "personalization", "=", "new", "Personalization", "(", ")", ";", "$", "personalization", "->", "$", "personalizationFunctionCall", "(", "$", "email", ")", ";", "if", "(", "$", "subs", "=", "$", "email", "->", "getSubstitutions", "(", ")", ")", "{", "foreach", "(", "$", "subs", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "personalization", "->", "addSubstitution", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "if", "(", "(", "$", "personalizationIndex", "!=", "0", ")", "&&", "(", "$", "this", "->", "getPersonalizationCount", "(", ")", "<=", "$", "personalizationIndex", ")", ")", "{", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "=", "$", "personalization", ";", "}", "else", "{", "$", "this", "->", "addPersonalization", "(", "$", "personalization", ")", ";", "}", "return", ";", "}", "}", "}" ]
Adds a To, Cc or Bcc object to a Personalization object @param string $emailType Object type name: To, Cc or Bcc @param string $email Recipient email address @param string|null $name Recipient name @param Substitution[]|array|null $substitutions Personalized substitutions @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object @return null
[ "Adds", "a", "To", "Cc", "or", "Bcc", "object", "to", "a", "Personalization", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L187-L260
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addRecipientEmails
private function addRecipientEmails( $emailType, $emails, $personalizationIndex = null, $personalization = null ) { $emailFunctionCall = "add" . $emailType; if (current($emails) instanceof EmailAddress) { foreach ($emails as $email) { $this->$emailFunctionCall( $email, $name = null, $personalizationIndex, $personalization ); } } else { foreach ($emails as $email => $name) { $this->$emailFunctionCall( $email, $name, $personalizationIndex, $personalization ); } } }
php
private function addRecipientEmails( $emailType, $emails, $personalizationIndex = null, $personalization = null ) { $emailFunctionCall = "add" . $emailType; if (current($emails) instanceof EmailAddress) { foreach ($emails as $email) { $this->$emailFunctionCall( $email, $name = null, $personalizationIndex, $personalization ); } } else { foreach ($emails as $email => $name) { $this->$emailFunctionCall( $email, $name, $personalizationIndex, $personalization ); } } }
[ "private", "function", "addRecipientEmails", "(", "$", "emailType", ",", "$", "emails", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "$", "emailFunctionCall", "=", "\"add\"", ".", "$", "emailType", ";", "if", "(", "current", "(", "$", "emails", ")", "instanceof", "EmailAddress", ")", "{", "foreach", "(", "$", "emails", "as", "$", "email", ")", "{", "$", "this", "->", "$", "emailFunctionCall", "(", "$", "email", ",", "$", "name", "=", "null", ",", "$", "personalizationIndex", ",", "$", "personalization", ")", ";", "}", "}", "else", "{", "foreach", "(", "$", "emails", "as", "$", "email", "=>", "$", "name", ")", "{", "$", "this", "->", "$", "emailFunctionCall", "(", "$", "email", ",", "$", "name", ",", "$", "personalizationIndex", ",", "$", "personalization", ")", ";", "}", "}", "}" ]
Adds an array of To, Cc or Bcc objects to a Personalization object @param string $emailType Object type name: To, Cc or Bcc @param To[]|Cc[]|Bcc[] $emails Array of email recipients @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A Personalization object
[ "Adds", "an", "array", "of", "To", "Cc", "or", "Bcc", "objects", "to", "a", "Personalization", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L273-L300
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addTo
public function addTo( $to, $name = null, $substitutions = null, $personalizationIndex = null, $personalization = null ) { if ($to instanceof To) { $name = $to->getName(); $substitutions = $to->getSubstitutions(); $to = $to->getEmailAddress(); } $this->addRecipientEmail( "To", $to, $name, $substitutions, $personalizationIndex, $personalization ); }
php
public function addTo( $to, $name = null, $substitutions = null, $personalizationIndex = null, $personalization = null ) { if ($to instanceof To) { $name = $to->getName(); $substitutions = $to->getSubstitutions(); $to = $to->getEmailAddress(); } $this->addRecipientEmail( "To", $to, $name, $substitutions, $personalizationIndex, $personalization ); }
[ "public", "function", "addTo", "(", "$", "to", ",", "$", "name", "=", "null", ",", "$", "substitutions", "=", "null", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "if", "(", "$", "to", "instanceof", "To", ")", "{", "$", "name", "=", "$", "to", "->", "getName", "(", ")", ";", "$", "substitutions", "=", "$", "to", "->", "getSubstitutions", "(", ")", ";", "$", "to", "=", "$", "to", "->", "getEmailAddress", "(", ")", ";", "}", "$", "this", "->", "addRecipientEmail", "(", "\"To\"", ",", "$", "to", ",", "$", "name", ",", "$", "substitutions", ",", "$", "personalizationIndex", ",", "$", "personalization", ")", ";", "}" ]
Adds an email recipient to a Personalization object @param string|To $to Email address or To object @param string $name Recipient name @param array|Substitution[] $substitutions Personalized substitutions @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object
[ "Adds", "an", "email", "recipient", "to", "a", "Personalization", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L344-L364
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addTos
public function addTos( $toEmails, $personalizationIndex = null, $personalization = null ) { $this->addRecipientEmails( "To", $toEmails, $personalizationIndex, $personalization ); }
php
public function addTos( $toEmails, $personalizationIndex = null, $personalization = null ) { $this->addRecipientEmails( "To", $toEmails, $personalizationIndex, $personalization ); }
[ "public", "function", "addTos", "(", "$", "toEmails", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "$", "this", "->", "addRecipientEmails", "(", "\"To\"", ",", "$", "toEmails", ",", "$", "personalizationIndex", ",", "$", "personalization", ")", ";", "}" ]
Adds multiple email recipients to a Personalization object @param To[]|array $toEmails Array of To objects or key/value pairs of email address/recipient names @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object
[ "Adds", "multiple", "email", "recipients", "to", "a", "Personalization", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L378-L389
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addCc
public function addCc( $cc, $name = null, $personalizationIndex = null, $personalization = null ) { if ($cc instanceof Cc) { $name = $cc->getName(); $cc = $cc->getEmailAddress(); } $this->addRecipientEmail( "Cc", $cc, $name, $personalizationIndex, $personalization ); }
php
public function addCc( $cc, $name = null, $personalizationIndex = null, $personalization = null ) { if ($cc instanceof Cc) { $name = $cc->getName(); $cc = $cc->getEmailAddress(); } $this->addRecipientEmail( "Cc", $cc, $name, $personalizationIndex, $personalization ); }
[ "public", "function", "addCc", "(", "$", "cc", ",", "$", "name", "=", "null", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "if", "(", "$", "cc", "instanceof", "Cc", ")", "{", "$", "name", "=", "$", "cc", "->", "getName", "(", ")", ";", "$", "cc", "=", "$", "cc", "->", "getEmailAddress", "(", ")", ";", "}", "$", "this", "->", "addRecipientEmail", "(", "\"Cc\"", ",", "$", "cc", ",", "$", "name", ",", "$", "personalizationIndex", ",", "$", "personalization", ")", ";", "}" ]
Adds an email cc recipient to a Personalization object @param string|Cc $cc Email address or Cc object @param string $name Recipient name @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object
[ "Adds", "an", "email", "cc", "recipient", "to", "a", "Personalization", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L402-L419
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addCcs
public function addCcs( $ccEmails, $personalizationIndex = null, $personalization = null ) { $this->addRecipientEmails( "Cc", $ccEmails, $personalizationIndex, $personalization ); }
php
public function addCcs( $ccEmails, $personalizationIndex = null, $personalization = null ) { $this->addRecipientEmails( "Cc", $ccEmails, $personalizationIndex, $personalization ); }
[ "public", "function", "addCcs", "(", "$", "ccEmails", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "$", "this", "->", "addRecipientEmails", "(", "\"Cc\"", ",", "$", "ccEmails", ",", "$", "personalizationIndex", ",", "$", "personalization", ")", ";", "}" ]
Adds multiple email cc recipients to a Personalization object @param Cc[]|array $ccEmails Array of Cc objects or key/value pairs of email address/recipient names @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object
[ "Adds", "multiple", "email", "cc", "recipients", "to", "a", "Personalization", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L433-L444
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addBcc
public function addBcc( $bcc, $name = null, $personalizationIndex = null, $personalization = null ) { if ($bcc instanceof Bcc) { $name = $bcc->getName(); $bcc = $bcc->getEmailAddress(); } $this->addRecipientEmail( "Bcc", $bcc, $name, $personalizationIndex, $personalization ); }
php
public function addBcc( $bcc, $name = null, $personalizationIndex = null, $personalization = null ) { if ($bcc instanceof Bcc) { $name = $bcc->getName(); $bcc = $bcc->getEmailAddress(); } $this->addRecipientEmail( "Bcc", $bcc, $name, $personalizationIndex, $personalization ); }
[ "public", "function", "addBcc", "(", "$", "bcc", ",", "$", "name", "=", "null", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "if", "(", "$", "bcc", "instanceof", "Bcc", ")", "{", "$", "name", "=", "$", "bcc", "->", "getName", "(", ")", ";", "$", "bcc", "=", "$", "bcc", "->", "getEmailAddress", "(", ")", ";", "}", "$", "this", "->", "addRecipientEmail", "(", "\"Bcc\"", ",", "$", "bcc", ",", "$", "name", ",", "$", "personalizationIndex", ",", "$", "personalization", ")", ";", "}" ]
Adds an email bcc recipient to a Personalization object @param string|Bcc $bcc Email address or Bcc object @param string $name Recipient name @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object
[ "Adds", "an", "email", "bcc", "recipient", "to", "a", "Personalization", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L457-L474
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addBccs
public function addBccs( $bccEmails, $personalizationIndex = null, $personalization = null ) { $this->addRecipientEmails( "Bcc", $bccEmails, $personalizationIndex, $personalization ); }
php
public function addBccs( $bccEmails, $personalizationIndex = null, $personalization = null ) { $this->addRecipientEmails( "Bcc", $bccEmails, $personalizationIndex, $personalization ); }
[ "public", "function", "addBccs", "(", "$", "bccEmails", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "$", "this", "->", "addRecipientEmails", "(", "\"Bcc\"", ",", "$", "bccEmails", ",", "$", "personalizationIndex", ",", "$", "personalization", ")", ";", "}" ]
Adds multiple email bcc recipients to a Personalization object @param Bcc[]|array $bccEmails Array of Bcc objects or key/value pairs of email address/recipient names @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object
[ "Adds", "multiple", "email", "bcc", "recipients", "to", "a", "Personalization", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L488-L499
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setSubject
public function setSubject( $subject, $personalizationIndex = null, $personalization = null ) { if (!($subject instanceof Subject)) { $subject = new Subject($subject); } if ($personalization != null) { $personalization->setSubject($subject); $this->addPersonalization($personalization); return; } if ($personalizationIndex != null) { $this->personalization[$personalizationIndex]->setSubject($subject); return; } $this->setGlobalSubject($subject); return; }
php
public function setSubject( $subject, $personalizationIndex = null, $personalization = null ) { if (!($subject instanceof Subject)) { $subject = new Subject($subject); } if ($personalization != null) { $personalization->setSubject($subject); $this->addPersonalization($personalization); return; } if ($personalizationIndex != null) { $this->personalization[$personalizationIndex]->setSubject($subject); return; } $this->setGlobalSubject($subject); return; }
[ "public", "function", "setSubject", "(", "$", "subject", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "if", "(", "!", "(", "$", "subject", "instanceof", "Subject", ")", ")", "{", "$", "subject", "=", "new", "Subject", "(", "$", "subject", ")", ";", "}", "if", "(", "$", "personalization", "!=", "null", ")", "{", "$", "personalization", "->", "setSubject", "(", "$", "subject", ")", ";", "$", "this", "->", "addPersonalization", "(", "$", "personalization", ")", ";", "return", ";", "}", "if", "(", "$", "personalizationIndex", "!=", "null", ")", "{", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "->", "setSubject", "(", "$", "subject", ")", ";", "return", ";", "}", "$", "this", "->", "setGlobalSubject", "(", "$", "subject", ")", ";", "return", ";", "}" ]
Add a subject to a Personalization or Mail object If you don't provide a Personalization object or index, the subject will be global to entire message. Note that subjects added to Personalization objects override global subjects. @param string|Subject $subject Email subject @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object
[ "Add", "a", "subject", "to", "a", "Personalization", "or", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L516-L536
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addHeader
public function addHeader( $key, $value = null, $personalizationIndex = null, $personalization = null ) { $header = null; if ($key instanceof Header) { $h = $key; $header = new Header($h->getKey(), $h->getValue()); } else { $header = new Header($key, $value); } if ($personalization != null) { $personalization->addHeader($header); $this->addPersonalization($personalization); return; } else { if ($this->personalization[0] != null) { $this->personalization[0]->addHeader($header); } else if ($this->personalization[$personalizationIndex] != null) { $this->personalization[$personalizationIndex]->addHeader($header); } else { $personalization = new Personalization(); $personalization->addHeader($header); if (($personalizationIndex != 0) && ($this->getPersonalizationCount() <= $personalizationIndex) ) { $this->personalization[$personalizationIndex] = $personalization; } else { $this->addPersonalization($personalization); } } return; } }
php
public function addHeader( $key, $value = null, $personalizationIndex = null, $personalization = null ) { $header = null; if ($key instanceof Header) { $h = $key; $header = new Header($h->getKey(), $h->getValue()); } else { $header = new Header($key, $value); } if ($personalization != null) { $personalization->addHeader($header); $this->addPersonalization($personalization); return; } else { if ($this->personalization[0] != null) { $this->personalization[0]->addHeader($header); } else if ($this->personalization[$personalizationIndex] != null) { $this->personalization[$personalizationIndex]->addHeader($header); } else { $personalization = new Personalization(); $personalization->addHeader($header); if (($personalizationIndex != 0) && ($this->getPersonalizationCount() <= $personalizationIndex) ) { $this->personalization[$personalizationIndex] = $personalization; } else { $this->addPersonalization($personalization); } } return; } }
[ "public", "function", "addHeader", "(", "$", "key", ",", "$", "value", "=", "null", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "$", "header", "=", "null", ";", "if", "(", "$", "key", "instanceof", "Header", ")", "{", "$", "h", "=", "$", "key", ";", "$", "header", "=", "new", "Header", "(", "$", "h", "->", "getKey", "(", ")", ",", "$", "h", "->", "getValue", "(", ")", ")", ";", "}", "else", "{", "$", "header", "=", "new", "Header", "(", "$", "key", ",", "$", "value", ")", ";", "}", "if", "(", "$", "personalization", "!=", "null", ")", "{", "$", "personalization", "->", "addHeader", "(", "$", "header", ")", ";", "$", "this", "->", "addPersonalization", "(", "$", "personalization", ")", ";", "return", ";", "}", "else", "{", "if", "(", "$", "this", "->", "personalization", "[", "0", "]", "!=", "null", ")", "{", "$", "this", "->", "personalization", "[", "0", "]", "->", "addHeader", "(", "$", "header", ")", ";", "}", "else", "if", "(", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "!=", "null", ")", "{", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "->", "addHeader", "(", "$", "header", ")", ";", "}", "else", "{", "$", "personalization", "=", "new", "Personalization", "(", ")", ";", "$", "personalization", "->", "addHeader", "(", "$", "header", ")", ";", "if", "(", "(", "$", "personalizationIndex", "!=", "0", ")", "&&", "(", "$", "this", "->", "getPersonalizationCount", "(", ")", "<=", "$", "personalizationIndex", ")", ")", "{", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "=", "$", "personalization", ";", "}", "else", "{", "$", "this", "->", "addPersonalization", "(", "$", "personalization", ")", ";", "}", "}", "return", ";", "}", "}" ]
Add a header to a Personalization or Mail object If you don't provide a Personalization object or index, the header will be global to entire message. Note that headers added to Personalization objects override global headers. @param string|Header $key Key or Header object @param string|null $value Value @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object
[ "Add", "a", "header", "to", "a", "Personalization", "or", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L568-L603
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addHeaders
public function addHeaders( $headers, $personalizationIndex = null, $personalization = null ) { if (current($headers) instanceof Header) { foreach ($headers as $header) { $this->addHeader($header); } } else { foreach ($headers as $key => $value) { $this->addHeader( $key, $value, $personalizationIndex, $personalization ); } } }
php
public function addHeaders( $headers, $personalizationIndex = null, $personalization = null ) { if (current($headers) instanceof Header) { foreach ($headers as $header) { $this->addHeader($header); } } else { foreach ($headers as $key => $value) { $this->addHeader( $key, $value, $personalizationIndex, $personalization ); } } }
[ "public", "function", "addHeaders", "(", "$", "headers", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "if", "(", "current", "(", "$", "headers", ")", "instanceof", "Header", ")", "{", "foreach", "(", "$", "headers", "as", "$", "header", ")", "{", "$", "this", "->", "addHeader", "(", "$", "header", ")", ";", "}", "}", "else", "{", "foreach", "(", "$", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "addHeader", "(", "$", "key", ",", "$", "value", ",", "$", "personalizationIndex", ",", "$", "personalization", ")", ";", "}", "}", "}" ]
Adds multiple headers to a Personalization or Mail object If you don't provide a Personalization object or index, the header will be global to entire message. Note that headers added to Personalization objects override global headers. @param array|Header[] $headers Array of Header objects or key values @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object
[ "Adds", "multiple", "headers", "to", "a", "Personalization", "or", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L621-L640
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addSubstitution
public function addSubstitution( $key, $value = null, $personalizationIndex = null, $personalization = null ) { $substitution = null; if ($key instanceof Substitution) { $s = $key; $substitution = new Substitution($s->getKey(), $s->getValue()); } else { $substitution = new Substitution($key, $value); } if ($personalization != null) { $personalization->addSubstitution($substitution); $this->addPersonalization($personalization); return; } else { if ($this->personalization[0] != null) { $this->personalization[0]->addSubstitution($substitution); } else if ($this->personalization[$personalizationIndex] != null) { $this->personalization[$personalizationIndex]->addSubstitution($substitution); } else { $personalization = new Personalization(); $personalization->addSubstitution($substitution); if (($personalizationIndex != 0) && ($this->getPersonalizationCount() <= $personalizationIndex) ) { $this->personalization[$personalizationIndex] = $personalization; } else { $this->addPersonalization($personalization); } } return; } }
php
public function addSubstitution( $key, $value = null, $personalizationIndex = null, $personalization = null ) { $substitution = null; if ($key instanceof Substitution) { $s = $key; $substitution = new Substitution($s->getKey(), $s->getValue()); } else { $substitution = new Substitution($key, $value); } if ($personalization != null) { $personalization->addSubstitution($substitution); $this->addPersonalization($personalization); return; } else { if ($this->personalization[0] != null) { $this->personalization[0]->addSubstitution($substitution); } else if ($this->personalization[$personalizationIndex] != null) { $this->personalization[$personalizationIndex]->addSubstitution($substitution); } else { $personalization = new Personalization(); $personalization->addSubstitution($substitution); if (($personalizationIndex != 0) && ($this->getPersonalizationCount() <= $personalizationIndex) ) { $this->personalization[$personalizationIndex] = $personalization; } else { $this->addPersonalization($personalization); } } return; } }
[ "public", "function", "addSubstitution", "(", "$", "key", ",", "$", "value", "=", "null", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "$", "substitution", "=", "null", ";", "if", "(", "$", "key", "instanceof", "Substitution", ")", "{", "$", "s", "=", "$", "key", ";", "$", "substitution", "=", "new", "Substitution", "(", "$", "s", "->", "getKey", "(", ")", ",", "$", "s", "->", "getValue", "(", ")", ")", ";", "}", "else", "{", "$", "substitution", "=", "new", "Substitution", "(", "$", "key", ",", "$", "value", ")", ";", "}", "if", "(", "$", "personalization", "!=", "null", ")", "{", "$", "personalization", "->", "addSubstitution", "(", "$", "substitution", ")", ";", "$", "this", "->", "addPersonalization", "(", "$", "personalization", ")", ";", "return", ";", "}", "else", "{", "if", "(", "$", "this", "->", "personalization", "[", "0", "]", "!=", "null", ")", "{", "$", "this", "->", "personalization", "[", "0", "]", "->", "addSubstitution", "(", "$", "substitution", ")", ";", "}", "else", "if", "(", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "!=", "null", ")", "{", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "->", "addSubstitution", "(", "$", "substitution", ")", ";", "}", "else", "{", "$", "personalization", "=", "new", "Personalization", "(", ")", ";", "$", "personalization", "->", "addSubstitution", "(", "$", "substitution", ")", ";", "if", "(", "(", "$", "personalizationIndex", "!=", "0", ")", "&&", "(", "$", "this", "->", "getPersonalizationCount", "(", ")", "<=", "$", "personalizationIndex", ")", ")", "{", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "=", "$", "personalization", ";", "}", "else", "{", "$", "this", "->", "addPersonalization", "(", "$", "personalization", ")", ";", "}", "}", "return", ";", "}", "}" ]
Add a substitution to a Personalization or Mail object If you don't provide a Personalization object or index, the substitution will be global to entire message. Note that substitutions added to Personalization objects override global substitutions. @param string|Substitution $key Key or Substitution object @param string|null $value Value @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object @return null
[ "Add", "a", "substitution", "to", "a", "Personalization", "or", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L727-L762
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addSubstitutions
public function addSubstitutions( $substitutions, $personalizationIndex = null, $personalization = null ) { if (current($substitutions) instanceof Substitution) { foreach ($substitutions as $substitution) { $this->addSubstitution($substitution); } } else { foreach ($substitutions as $key => $value) { $this->addSubstitution( $key, $value, $personalizationIndex, $personalization ); } } }
php
public function addSubstitutions( $substitutions, $personalizationIndex = null, $personalization = null ) { if (current($substitutions) instanceof Substitution) { foreach ($substitutions as $substitution) { $this->addSubstitution($substitution); } } else { foreach ($substitutions as $key => $value) { $this->addSubstitution( $key, $value, $personalizationIndex, $personalization ); } } }
[ "public", "function", "addSubstitutions", "(", "$", "substitutions", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "if", "(", "current", "(", "$", "substitutions", ")", "instanceof", "Substitution", ")", "{", "foreach", "(", "$", "substitutions", "as", "$", "substitution", ")", "{", "$", "this", "->", "addSubstitution", "(", "$", "substitution", ")", ";", "}", "}", "else", "{", "foreach", "(", "$", "substitutions", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "addSubstitution", "(", "$", "key", ",", "$", "value", ",", "$", "personalizationIndex", ",", "$", "personalization", ")", ";", "}", "}", "}" ]
Adds multiple substitutions to a Personalization or Mail object If you don't provide a Personalization object or index, the substitution will be global to entire message. Note that substitutions added to Personalization objects override global headers. @param array|Substitution[] $substitutions Array of Substitution objects or key/values @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created ersonalization object
[ "Adds", "multiple", "substitutions", "to", "a", "Personalization", "or", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L780-L799
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addCustomArg
public function addCustomArg( $key, $value = null, $personalizationIndex = null, $personalization = null ) { $custom_arg = null; if ($key instanceof CustomArg) { $ca = $key; $custom_arg = new CustomArg($ca->getKey(), $ca->getValue()); } else { $custom_arg = new CustomArg($key, $value); } if ($personalization != null) { $personalization->addCustomArg($custom_arg); $this->addPersonalization($personalization); return; } else { if ($this->personalization[0] != null) { $this->personalization[0]->addCustomArg($custom_arg); } else if ($this->personalization[$personalizationIndex] != null) { $this->personalization[$personalizationIndex]->addCustomArg( $custom_arg ); } else { $personalization = new Personalization(); $personalization->addCustomArg($custom_arg); if (($personalizationIndex != 0) && ($this->getPersonalizationCount() <= $personalizationIndex) ) { $this->personalization[$personalizationIndex] = $personalization; } else { $this->addPersonalization($personalization); } } return; } }
php
public function addCustomArg( $key, $value = null, $personalizationIndex = null, $personalization = null ) { $custom_arg = null; if ($key instanceof CustomArg) { $ca = $key; $custom_arg = new CustomArg($ca->getKey(), $ca->getValue()); } else { $custom_arg = new CustomArg($key, $value); } if ($personalization != null) { $personalization->addCustomArg($custom_arg); $this->addPersonalization($personalization); return; } else { if ($this->personalization[0] != null) { $this->personalization[0]->addCustomArg($custom_arg); } else if ($this->personalization[$personalizationIndex] != null) { $this->personalization[$personalizationIndex]->addCustomArg( $custom_arg ); } else { $personalization = new Personalization(); $personalization->addCustomArg($custom_arg); if (($personalizationIndex != 0) && ($this->getPersonalizationCount() <= $personalizationIndex) ) { $this->personalization[$personalizationIndex] = $personalization; } else { $this->addPersonalization($personalization); } } return; } }
[ "public", "function", "addCustomArg", "(", "$", "key", ",", "$", "value", "=", "null", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "$", "custom_arg", "=", "null", ";", "if", "(", "$", "key", "instanceof", "CustomArg", ")", "{", "$", "ca", "=", "$", "key", ";", "$", "custom_arg", "=", "new", "CustomArg", "(", "$", "ca", "->", "getKey", "(", ")", ",", "$", "ca", "->", "getValue", "(", ")", ")", ";", "}", "else", "{", "$", "custom_arg", "=", "new", "CustomArg", "(", "$", "key", ",", "$", "value", ")", ";", "}", "if", "(", "$", "personalization", "!=", "null", ")", "{", "$", "personalization", "->", "addCustomArg", "(", "$", "custom_arg", ")", ";", "$", "this", "->", "addPersonalization", "(", "$", "personalization", ")", ";", "return", ";", "}", "else", "{", "if", "(", "$", "this", "->", "personalization", "[", "0", "]", "!=", "null", ")", "{", "$", "this", "->", "personalization", "[", "0", "]", "->", "addCustomArg", "(", "$", "custom_arg", ")", ";", "}", "else", "if", "(", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "!=", "null", ")", "{", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "->", "addCustomArg", "(", "$", "custom_arg", ")", ";", "}", "else", "{", "$", "personalization", "=", "new", "Personalization", "(", ")", ";", "$", "personalization", "->", "addCustomArg", "(", "$", "custom_arg", ")", ";", "if", "(", "(", "$", "personalizationIndex", "!=", "0", ")", "&&", "(", "$", "this", "->", "getPersonalizationCount", "(", ")", "<=", "$", "personalizationIndex", ")", ")", "{", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "=", "$", "personalization", ";", "}", "else", "{", "$", "this", "->", "addPersonalization", "(", "$", "personalization", ")", ";", "}", "}", "return", ";", "}", "}" ]
Add a custom arg to a Personalization or Mail object Note that custom args added to Personalization objects override global custom args. @param string|CustomArg $key Key or CustomArg object @param string|null $value Value @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object
[ "Add", "a", "custom", "arg", "to", "a", "Personalization", "or", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L829-L866
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addCustomArgs
public function addCustomArgs( $custom_args, $personalizationIndex = null, $personalization = null ) { if (current($custom_args) instanceof CustomArg) { foreach ($custom_args as $custom_arg) { $this->addCustomArg($custom_arg); } } else { foreach ($custom_args as $key => $value) { $this->addCustomArg( $key, $value, $personalizationIndex, $personalization ); } } }
php
public function addCustomArgs( $custom_args, $personalizationIndex = null, $personalization = null ) { if (current($custom_args) instanceof CustomArg) { foreach ($custom_args as $custom_arg) { $this->addCustomArg($custom_arg); } } else { foreach ($custom_args as $key => $value) { $this->addCustomArg( $key, $value, $personalizationIndex, $personalization ); } } }
[ "public", "function", "addCustomArgs", "(", "$", "custom_args", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "if", "(", "current", "(", "$", "custom_args", ")", "instanceof", "CustomArg", ")", "{", "foreach", "(", "$", "custom_args", "as", "$", "custom_arg", ")", "{", "$", "this", "->", "addCustomArg", "(", "$", "custom_arg", ")", ";", "}", "}", "else", "{", "foreach", "(", "$", "custom_args", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "addCustomArg", "(", "$", "key", ",", "$", "value", ",", "$", "personalizationIndex", ",", "$", "personalization", ")", ";", "}", "}", "}" ]
Adds multiple custom args to a Personalization or Mail object If you don't provide a Personalization object or index, the custom arg will be global to entire message. Note that custom args added to Personalization objects override global custom args. @param array|CustomArg[] $custom_args Array of CustomArg objects or key/values @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object
[ "Adds", "multiple", "custom", "args", "to", "a", "Personalization", "or", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L884-L903
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setSendAt
public function setSendAt( $send_at, $personalizationIndex = null, $personalization = null ) { if (!($send_at instanceof SendAt)) { $send_at = new SendAt($send_at); } if ($personalization != null) { $personalization->setSendAt($send_at); $this->addPersonalization($personalization); return; } else { if ($this->personalization[0] != null) { $this->personalization[0]->setSendAt($send_at); return; } else if ($this->personalization[$personalizationIndex] != null) { $this->personalization[$personalizationIndex]->setSendAt($send_at); return; } else { $personalization = new Personalization(); $personalization->setSendAt($send_at); if (($personalizationIndex != 0) && ($this->getPersonalizationCount() <= $personalizationIndex) ) { $this->personalization[$personalizationIndex] = $personalization; } else { $this->addPersonalization($personalization); } return; } } }
php
public function setSendAt( $send_at, $personalizationIndex = null, $personalization = null ) { if (!($send_at instanceof SendAt)) { $send_at = new SendAt($send_at); } if ($personalization != null) { $personalization->setSendAt($send_at); $this->addPersonalization($personalization); return; } else { if ($this->personalization[0] != null) { $this->personalization[0]->setSendAt($send_at); return; } else if ($this->personalization[$personalizationIndex] != null) { $this->personalization[$personalizationIndex]->setSendAt($send_at); return; } else { $personalization = new Personalization(); $personalization->setSendAt($send_at); if (($personalizationIndex != 0) && ($this->getPersonalizationCount() <= $personalizationIndex) ) { $this->personalization[$personalizationIndex] = $personalization; } else { $this->addPersonalization($personalization); } return; } } }
[ "public", "function", "setSendAt", "(", "$", "send_at", ",", "$", "personalizationIndex", "=", "null", ",", "$", "personalization", "=", "null", ")", "{", "if", "(", "!", "(", "$", "send_at", "instanceof", "SendAt", ")", ")", "{", "$", "send_at", "=", "new", "SendAt", "(", "$", "send_at", ")", ";", "}", "if", "(", "$", "personalization", "!=", "null", ")", "{", "$", "personalization", "->", "setSendAt", "(", "$", "send_at", ")", ";", "$", "this", "->", "addPersonalization", "(", "$", "personalization", ")", ";", "return", ";", "}", "else", "{", "if", "(", "$", "this", "->", "personalization", "[", "0", "]", "!=", "null", ")", "{", "$", "this", "->", "personalization", "[", "0", "]", "->", "setSendAt", "(", "$", "send_at", ")", ";", "return", ";", "}", "else", "if", "(", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "!=", "null", ")", "{", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "->", "setSendAt", "(", "$", "send_at", ")", ";", "return", ";", "}", "else", "{", "$", "personalization", "=", "new", "Personalization", "(", ")", ";", "$", "personalization", "->", "setSendAt", "(", "$", "send_at", ")", ";", "if", "(", "(", "$", "personalizationIndex", "!=", "0", ")", "&&", "(", "$", "this", "->", "getPersonalizationCount", "(", ")", "<=", "$", "personalizationIndex", ")", ")", "{", "$", "this", "->", "personalization", "[", "$", "personalizationIndex", "]", "=", "$", "personalization", ";", "}", "else", "{", "$", "this", "->", "addPersonalization", "(", "$", "personalization", ")", ";", "}", "return", ";", "}", "}", "}" ]
Add a unix timestamp allowing you to specify when you want your email to be delivered to a Personalization or Mail object If you don't provide a Personalization object or index, the send at timestamp will be global to entire message. Note that timestamps added to Personalization objects override global timestamps. @param int|SendAt $send_at A unix timestamp @param int|null $personalizationIndex Index into an array of existing Personalization objects @param Personalization|null $personalization A pre-created Personalization object
[ "Add", "a", "unix", "timestamp", "allowing", "you", "to", "specify", "when", "you", "want", "your", "email", "to", "be", "delivered", "to", "a", "Personalization", "or", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L935-L967
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setFrom
public function setFrom($email, $name = null) { if ($email instanceof From) { $this->from = $email; } else { if ( is_string($email) && filter_var($email, FILTER_VALIDATE_EMAIL) ) { $this->from = new From($email, $name); } else { throw new TypeException( '$email must be valid and of type string.' ); } } return; }
php
public function setFrom($email, $name = null) { if ($email instanceof From) { $this->from = $email; } else { if ( is_string($email) && filter_var($email, FILTER_VALIDATE_EMAIL) ) { $this->from = new From($email, $name); } else { throw new TypeException( '$email must be valid and of type string.' ); } } return; }
[ "public", "function", "setFrom", "(", "$", "email", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "email", "instanceof", "From", ")", "{", "$", "this", "->", "from", "=", "$", "email", ";", "}", "else", "{", "if", "(", "is_string", "(", "$", "email", ")", "&&", "filter_var", "(", "$", "email", ",", "FILTER_VALIDATE_EMAIL", ")", ")", "{", "$", "this", "->", "from", "=", "new", "From", "(", "$", "email", ",", "$", "name", ")", ";", "}", "else", "{", "throw", "new", "TypeException", "(", "'$email must be valid and of type string.'", ")", ";", "}", "}", "return", ";", "}" ]
Add the sender email address to a Mail object @param string|From $email Email address or From object @param string|null $name Sender name @throws TypeException
[ "Add", "the", "sender", "email", "address", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L991-L1009
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setReplyTo
public function setReplyTo($email, $name = null) { if ($email instanceof ReplyTo) { $this->reply_to = $email; } else { $this->reply_to = new ReplyTo($email, $name); } }
php
public function setReplyTo($email, $name = null) { if ($email instanceof ReplyTo) { $this->reply_to = $email; } else { $this->reply_to = new ReplyTo($email, $name); } }
[ "public", "function", "setReplyTo", "(", "$", "email", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "email", "instanceof", "ReplyTo", ")", "{", "$", "this", "->", "reply_to", "=", "$", "email", ";", "}", "else", "{", "$", "this", "->", "reply_to", "=", "new", "ReplyTo", "(", "$", "email", ",", "$", "name", ")", ";", "}", "}" ]
Add the reply to email address to a Mail object @param string|ReplyTo $email Email address or From object @param string|null $name Reply to name
[ "Add", "the", "reply", "to", "email", "address", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1027-L1034
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setGlobalSubject
public function setGlobalSubject($subject) { if (!($subject instanceof Subject)) { $subject = new Subject($subject); } $this->subject = $subject; }
php
public function setGlobalSubject($subject) { if (!($subject instanceof Subject)) { $subject = new Subject($subject); } $this->subject = $subject; }
[ "public", "function", "setGlobalSubject", "(", "$", "subject", ")", "{", "if", "(", "!", "(", "$", "subject", "instanceof", "Subject", ")", ")", "{", "$", "subject", "=", "new", "Subject", "(", "$", "subject", ")", ";", "}", "$", "this", "->", "subject", "=", "$", "subject", ";", "}" ]
Add a subject to a Mail object Note that subjects added to Personalization objects override global subjects. @param string|Subject $subject Email subject
[ "Add", "a", "subject", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1056-L1062
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addContent
public function addContent($type, $value = null) { if ($type instanceof Content) { $content = $type; } else { $content = new Content($type, $value); } $this->contents[] = $content; }
php
public function addContent($type, $value = null) { if ($type instanceof Content) { $content = $type; } else { $content = new Content($type, $value); } $this->contents[] = $content; }
[ "public", "function", "addContent", "(", "$", "type", ",", "$", "value", "=", "null", ")", "{", "if", "(", "$", "type", "instanceof", "Content", ")", "{", "$", "content", "=", "$", "type", ";", "}", "else", "{", "$", "content", "=", "new", "Content", "(", "$", "type", ",", "$", "value", ")", ";", "}", "$", "this", "->", "contents", "[", "]", "=", "$", "content", ";", "}" ]
Add content to a Mail object For a list of pre-configured mime types, please see MimeType.php @param string|Content $type Mime type or Content object @param string|null $value Contents (e.g. text or html)
[ "Add", "content", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1083-L1091
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addContents
public function addContents($contents) { if (current($contents) instanceof Content) { foreach ($contents as $content) { $this->addContent($content); } } else { foreach ($contents as $key => $value) { $this->addContent($key, $value); } } }
php
public function addContents($contents) { if (current($contents) instanceof Content) { foreach ($contents as $content) { $this->addContent($content); } } else { foreach ($contents as $key => $value) { $this->addContent($key, $value); } } }
[ "public", "function", "addContents", "(", "$", "contents", ")", "{", "if", "(", "current", "(", "$", "contents", ")", "instanceof", "Content", ")", "{", "foreach", "(", "$", "contents", "as", "$", "content", ")", "{", "$", "this", "->", "addContent", "(", "$", "content", ")", ";", "}", "}", "else", "{", "foreach", "(", "$", "contents", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "addContent", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "}" ]
Adds multiple Content objects to a Mail object @param array|Content[] $contents Array of Content objects or key value pairs
[ "Adds", "multiple", "Content", "objects", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1099-L1110
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.getContents
public function getContents() { if ($this->contents) { if ($this->contents[0]->getType() !== 'text/plain' && count($this->contents) > 1 ) { foreach ($this->contents as $key => $value) { if ($value->getType() == 'text/plain') { $plain_content = $value; unset($this->contents[$key]); break; } } array_unshift($this->contents, $plain_content); } } return $this->contents; }
php
public function getContents() { if ($this->contents) { if ($this->contents[0]->getType() !== 'text/plain' && count($this->contents) > 1 ) { foreach ($this->contents as $key => $value) { if ($value->getType() == 'text/plain') { $plain_content = $value; unset($this->contents[$key]); break; } } array_unshift($this->contents, $plain_content); } } return $this->contents; }
[ "public", "function", "getContents", "(", ")", "{", "if", "(", "$", "this", "->", "contents", ")", "{", "if", "(", "$", "this", "->", "contents", "[", "0", "]", "->", "getType", "(", ")", "!==", "'text/plain'", "&&", "count", "(", "$", "this", "->", "contents", ")", ">", "1", ")", "{", "foreach", "(", "$", "this", "->", "contents", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "->", "getType", "(", ")", "==", "'text/plain'", ")", "{", "$", "plain_content", "=", "$", "value", ";", "unset", "(", "$", "this", "->", "contents", "[", "$", "key", "]", ")", ";", "break", ";", "}", "}", "array_unshift", "(", "$", "this", "->", "contents", ",", "$", "plain_content", ")", ";", "}", "}", "return", "$", "this", "->", "contents", ";", "}" ]
Retrieve the contents attached to a Mail object Will return array of Content Objects with text/plain MimeType first Array re-ordered before return where this is not already the case @return Content[]
[ "Retrieve", "the", "contents", "attached", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1120-L1138
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addAttachment
public function addAttachment( $attachment, $type = null, $filename = null, $disposition = null, $content_id = null ) { if (is_array($attachment)) { $attachment = new Attachment( $attachment[0], $attachment[1], $attachment[2], $attachment[3], $attachment[4] ); } else if (!($attachment instanceof Attachment)) { $attachment = new Attachment( $attachment, $type, $filename, $disposition, $content_id ); } $this->attachments[] = $attachment; }
php
public function addAttachment( $attachment, $type = null, $filename = null, $disposition = null, $content_id = null ) { if (is_array($attachment)) { $attachment = new Attachment( $attachment[0], $attachment[1], $attachment[2], $attachment[3], $attachment[4] ); } else if (!($attachment instanceof Attachment)) { $attachment = new Attachment( $attachment, $type, $filename, $disposition, $content_id ); } $this->attachments[] = $attachment; }
[ "public", "function", "addAttachment", "(", "$", "attachment", ",", "$", "type", "=", "null", ",", "$", "filename", "=", "null", ",", "$", "disposition", "=", "null", ",", "$", "content_id", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "attachment", ")", ")", "{", "$", "attachment", "=", "new", "Attachment", "(", "$", "attachment", "[", "0", "]", ",", "$", "attachment", "[", "1", "]", ",", "$", "attachment", "[", "2", "]", ",", "$", "attachment", "[", "3", "]", ",", "$", "attachment", "[", "4", "]", ")", ";", "}", "else", "if", "(", "!", "(", "$", "attachment", "instanceof", "Attachment", ")", ")", "{", "$", "attachment", "=", "new", "Attachment", "(", "$", "attachment", ",", "$", "type", ",", "$", "filename", ",", "$", "disposition", ",", "$", "content_id", ")", ";", "}", "$", "this", "->", "attachments", "[", "]", "=", "$", "attachment", ";", "}" ]
Add an attachment to a Mail object @param string|Attachment $attachment Attachment object or Base64 encoded content @param string|null $type Mime type of the attachment @param string|null $filename File name of the attachment @param string|null $disposition How the attachment should be displayed: inline or attachment default is attachment @param string|null $content_id Used when disposition is inline to diplay the file within the body of the email
[ "Add", "an", "attachment", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1154-L1179
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setTemplateId
public function setTemplateId($template_id) { if (!($template_id instanceof TemplateId)) { $template_id = new TemplateId($template_id); } $this->template_id = $template_id; }
php
public function setTemplateId($template_id) { if (!($template_id instanceof TemplateId)) { $template_id = new TemplateId($template_id); } $this->template_id = $template_id; }
[ "public", "function", "setTemplateId", "(", "$", "template_id", ")", "{", "if", "(", "!", "(", "$", "template_id", "instanceof", "TemplateId", ")", ")", "{", "$", "template_id", "=", "new", "TemplateId", "(", "$", "template_id", ")", ";", "}", "$", "this", "->", "template_id", "=", "$", "template_id", ";", "}" ]
Add a template id to a Mail object @param string $template_id The id of the template to be appied to this email
[ "Add", "a", "template", "id", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1210-L1217
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addSection
public function addSection($key, $value = null) { if ($key instanceof Section) { $section = $key; $this->sections[$section->getKey()] = $section->getValue(); return; } $this->sections[$key] = (string)$value; }
php
public function addSection($key, $value = null) { if ($key instanceof Section) { $section = $key; $this->sections[$section->getKey()] = $section->getValue(); return; } $this->sections[$key] = (string)$value; }
[ "public", "function", "addSection", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "$", "key", "instanceof", "Section", ")", "{", "$", "section", "=", "$", "key", ";", "$", "this", "->", "sections", "[", "$", "section", "->", "getKey", "(", ")", "]", "=", "$", "section", "->", "getValue", "(", ")", ";", "return", ";", "}", "$", "this", "->", "sections", "[", "$", "key", "]", "=", "(", "string", ")", "$", "value", ";", "}" ]
Add a section to a Mail object @param string|Section $key Key or Section object @param string|null $value Value
[ "Add", "a", "section", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1235-L1244
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addSections
public function addSections($sections) { if (current($sections) instanceof Section) { foreach ($sections as $section) { $this->addSection($section); } } else { foreach ($sections as $key => $value) { $this->addSection($key, $value); } } }
php
public function addSections($sections) { if (current($sections) instanceof Section) { foreach ($sections as $section) { $this->addSection($section); } } else { foreach ($sections as $key => $value) { $this->addSection($key, $value); } } }
[ "public", "function", "addSections", "(", "$", "sections", ")", "{", "if", "(", "current", "(", "$", "sections", ")", "instanceof", "Section", ")", "{", "foreach", "(", "$", "sections", "as", "$", "section", ")", "{", "$", "this", "->", "addSection", "(", "$", "section", ")", ";", "}", "}", "else", "{", "foreach", "(", "$", "sections", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "addSection", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "}" ]
Adds multiple sections to a Mail object @param array|Section[] $sections Array of CustomArg objects or key/values
[ "Adds", "multiple", "sections", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1252-L1263
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addGlobalHeader
public function addGlobalHeader($key, $value = null) { if ($key instanceof Header) { $header = $key; $this->headers[$header->getKey()] = $header->getValue(); return; } $this->headers[$key] = (string)$value; }
php
public function addGlobalHeader($key, $value = null) { if ($key instanceof Header) { $header = $key; $this->headers[$header->getKey()] = $header->getValue(); return; } $this->headers[$key] = (string)$value; }
[ "public", "function", "addGlobalHeader", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "$", "key", "instanceof", "Header", ")", "{", "$", "header", "=", "$", "key", ";", "$", "this", "->", "headers", "[", "$", "header", "->", "getKey", "(", ")", "]", "=", "$", "header", "->", "getValue", "(", ")", ";", "return", ";", "}", "$", "this", "->", "headers", "[", "$", "key", "]", "=", "(", "string", ")", "$", "value", ";", "}" ]
Add a header to a Mail object Note that headers added to Personalization objects override global headers. @param string|Header $key Key or Header object @param string|null $value Value
[ "Add", "a", "header", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1284-L1293
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addGlobalHeaders
public function addGlobalHeaders($headers) { if (current($headers) instanceof Header) { foreach ($headers as $header) { $this->addGlobalHeader($header); } } else { foreach ($headers as $key => $value) { $this->addGlobalHeader($key, $value); } } }
php
public function addGlobalHeaders($headers) { if (current($headers) instanceof Header) { foreach ($headers as $header) { $this->addGlobalHeader($header); } } else { foreach ($headers as $key => $value) { $this->addGlobalHeader($key, $value); } } }
[ "public", "function", "addGlobalHeaders", "(", "$", "headers", ")", "{", "if", "(", "current", "(", "$", "headers", ")", "instanceof", "Header", ")", "{", "foreach", "(", "$", "headers", "as", "$", "header", ")", "{", "$", "this", "->", "addGlobalHeader", "(", "$", "header", ")", ";", "}", "}", "else", "{", "foreach", "(", "$", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "addGlobalHeader", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "}" ]
Adds multiple headers to a Mail object Note that headers added to Personalization objects override global headers. @param array|Header[] $headers Array of Header objects or key values
[ "Adds", "multiple", "headers", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1304-L1315
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addGlobalSubstitution
public function addGlobalSubstitution($key, $value = null) { if ($key instanceof Substitution) { $substitution = $key; $this->substitutions[$substitution->getKey()] = $substitution->getValue(); return; } $this->substitutions[$key] = $value; }
php
public function addGlobalSubstitution($key, $value = null) { if ($key instanceof Substitution) { $substitution = $key; $this->substitutions[$substitution->getKey()] = $substitution->getValue(); return; } $this->substitutions[$key] = $value; }
[ "public", "function", "addGlobalSubstitution", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "$", "key", "instanceof", "Substitution", ")", "{", "$", "substitution", "=", "$", "key", ";", "$", "this", "->", "substitutions", "[", "$", "substitution", "->", "getKey", "(", ")", "]", "=", "$", "substitution", "->", "getValue", "(", ")", ";", "return", ";", "}", "$", "this", "->", "substitutions", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Add a substitution to a Mail object Note that substitutions added to Personalization objects override global substitutions. @param string|Substitution $key Key or Substitution object @param string|null $value Value
[ "Add", "a", "substitution", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1336-L1345
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addGlobalSubstitutions
public function addGlobalSubstitutions($substitutions) { if (current($substitutions) instanceof Substitution) { foreach ($substitutions as $substitution) { $this->addGlobalSubstitution($substitution); } } else { foreach ($substitutions as $key => $value) { $this->addGlobalSubstitution($key, $value); } } }
php
public function addGlobalSubstitutions($substitutions) { if (current($substitutions) instanceof Substitution) { foreach ($substitutions as $substitution) { $this->addGlobalSubstitution($substitution); } } else { foreach ($substitutions as $key => $value) { $this->addGlobalSubstitution($key, $value); } } }
[ "public", "function", "addGlobalSubstitutions", "(", "$", "substitutions", ")", "{", "if", "(", "current", "(", "$", "substitutions", ")", "instanceof", "Substitution", ")", "{", "foreach", "(", "$", "substitutions", "as", "$", "substitution", ")", "{", "$", "this", "->", "addGlobalSubstitution", "(", "$", "substitution", ")", ";", "}", "}", "else", "{", "foreach", "(", "$", "substitutions", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "addGlobalSubstitution", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "}" ]
Adds multiple substitutions to a Mail object Note that substitutions added to Personalization objects override global headers. @param array|Substitution[] $substitutions Array of Substitution objects or key/values
[ "Adds", "multiple", "substitutions", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1356-L1367
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addCategory
public function addCategory($category) { if (!($category instanceof Category)) { $category = new Category($category); } $this->categories[] = $category; }
php
public function addCategory($category) { if (!($category instanceof Category)) { $category = new Category($category); } $this->categories[] = $category; }
[ "public", "function", "addCategory", "(", "$", "category", ")", "{", "if", "(", "!", "(", "$", "category", "instanceof", "Category", ")", ")", "{", "$", "category", "=", "new", "Category", "(", "$", "category", ")", ";", "}", "$", "this", "->", "categories", "[", "]", "=", "$", "category", ";", "}" ]
Add a category to a Mail object @param string|Category $category Category object or category name
[ "Add", "a", "category", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1384-L1390
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addGlobalCustomArg
public function addGlobalCustomArg($key, $value = null) { if ($key instanceof CustomArg) { $custom_arg = $key; $this->custom_args[$custom_arg->getKey()] = $custom_arg->getValue(); return; } $this->custom_args[$key] = (string)$value; }
php
public function addGlobalCustomArg($key, $value = null) { if ($key instanceof CustomArg) { $custom_arg = $key; $this->custom_args[$custom_arg->getKey()] = $custom_arg->getValue(); return; } $this->custom_args[$key] = (string)$value; }
[ "public", "function", "addGlobalCustomArg", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "$", "key", "instanceof", "CustomArg", ")", "{", "$", "custom_arg", "=", "$", "key", ";", "$", "this", "->", "custom_args", "[", "$", "custom_arg", "->", "getKey", "(", ")", "]", "=", "$", "custom_arg", "->", "getValue", "(", ")", ";", "return", ";", "}", "$", "this", "->", "custom_args", "[", "$", "key", "]", "=", "(", "string", ")", "$", "value", ";", "}" ]
Add a custom arg to a Mail object Note that custom args added to Personalization objects override global custom args. @param string|CustomArg $key Key or CustomArg object @param string|null $value Value
[ "Add", "a", "custom", "arg", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1425-L1434
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.addGlobalCustomArgs
public function addGlobalCustomArgs($custom_args) { if (current($custom_args) instanceof CustomArg) { foreach ($custom_args as $custom_arg) { $this->addGlobalCustomArg($custom_arg); } } else { foreach ($custom_args as $key => $value) { $this->addGlobalCustomArg($key, $value); } } }
php
public function addGlobalCustomArgs($custom_args) { if (current($custom_args) instanceof CustomArg) { foreach ($custom_args as $custom_arg) { $this->addGlobalCustomArg($custom_arg); } } else { foreach ($custom_args as $key => $value) { $this->addGlobalCustomArg($key, $value); } } }
[ "public", "function", "addGlobalCustomArgs", "(", "$", "custom_args", ")", "{", "if", "(", "current", "(", "$", "custom_args", ")", "instanceof", "CustomArg", ")", "{", "foreach", "(", "$", "custom_args", "as", "$", "custom_arg", ")", "{", "$", "this", "->", "addGlobalCustomArg", "(", "$", "custom_arg", ")", ";", "}", "}", "else", "{", "foreach", "(", "$", "custom_args", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "addGlobalCustomArg", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "}" ]
Adds multiple custom args to a Mail object Note that custom args added to Personalization objects override global custom args. @param array|CustomArg[] $custom_args Array of CustomArg objects or key/values
[ "Adds", "multiple", "custom", "args", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1445-L1456
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setGlobalSendAt
public function setGlobalSendAt($send_at) { if (!($send_at instanceof SendAt)) { $send_at = new SendAt($send_at); } $this->send_at = $send_at; }
php
public function setGlobalSendAt($send_at) { if (!($send_at instanceof SendAt)) { $send_at = new SendAt($send_at); } $this->send_at = $send_at; }
[ "public", "function", "setGlobalSendAt", "(", "$", "send_at", ")", "{", "if", "(", "!", "(", "$", "send_at", "instanceof", "SendAt", ")", ")", "{", "$", "send_at", "=", "new", "SendAt", "(", "$", "send_at", ")", ";", "}", "$", "this", "->", "send_at", "=", "$", "send_at", ";", "}" ]
Add a unix timestamp allowing you to specify when you want your email to be delivered to a Mail object Note that timestamps added to Personalization objects override global timestamps. @param int|SendAt $send_at A unix timestamp
[ "Add", "a", "unix", "timestamp", "allowing", "you", "to", "specify", "when", "you", "want", "your", "email", "to", "be", "delivered", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1477-L1483
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setBatchId
public function setBatchId($batch_id) { if (!($batch_id instanceof BatchId)) { $batch_id = new BatchId($batch_id); } $this->batch_id = $batch_id; }
php
public function setBatchId($batch_id) { if (!($batch_id instanceof BatchId)) { $batch_id = new BatchId($batch_id); } $this->batch_id = $batch_id; }
[ "public", "function", "setBatchId", "(", "$", "batch_id", ")", "{", "if", "(", "!", "(", "$", "batch_id", "instanceof", "BatchId", ")", ")", "{", "$", "batch_id", "=", "new", "BatchId", "(", "$", "batch_id", ")", ";", "}", "$", "this", "->", "batch_id", "=", "$", "batch_id", ";", "}" ]
Add a batch id to a Mail object @param string|BatchId $batch_id Id for a batch of emails to be sent at the same time
[ "Add", "a", "batch", "id", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1501-L1507
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setAsm
public function setAsm($group_id, $groups_to_display = null) { if ($group_id instanceof Asm) { $asm = $group_id; $this->asm = $asm; } else { $this->asm = new Asm($group_id, $groups_to_display); } }
php
public function setAsm($group_id, $groups_to_display = null) { if ($group_id instanceof Asm) { $asm = $group_id; $this->asm = $asm; } else { $this->asm = new Asm($group_id, $groups_to_display); } }
[ "public", "function", "setAsm", "(", "$", "group_id", ",", "$", "groups_to_display", "=", "null", ")", "{", "if", "(", "$", "group_id", "instanceof", "Asm", ")", "{", "$", "asm", "=", "$", "group_id", ";", "$", "this", "->", "asm", "=", "$", "asm", ";", "}", "else", "{", "$", "this", "->", "asm", "=", "new", "Asm", "(", "$", "group_id", ",", "$", "groups_to_display", ")", ";", "}", "}" ]
Add a Asm describing how to handle unsubscribes to a Mail object @param int|Asm $group_id Asm object or unsubscribe group id to associate this email with @param array $groups_to_display Array of integer ids of unsubscribe groups to be displayed on the unsubscribe preferences page
[ "Add", "a", "Asm", "describing", "how", "to", "handle", "unsubscribes", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1528-L1536
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setIpPoolName
public function setIpPoolName($ip_pool_name) { if ($ip_pool_name instanceof IpPoolName) { $this->ip_pool_name = $ip_pool_name->getIpPoolName(); } else { $this->ip_pool_name = new IpPoolName($ip_pool_name); } }
php
public function setIpPoolName($ip_pool_name) { if ($ip_pool_name instanceof IpPoolName) { $this->ip_pool_name = $ip_pool_name->getIpPoolName(); } else { $this->ip_pool_name = new IpPoolName($ip_pool_name); } }
[ "public", "function", "setIpPoolName", "(", "$", "ip_pool_name", ")", "{", "if", "(", "$", "ip_pool_name", "instanceof", "IpPoolName", ")", "{", "$", "this", "->", "ip_pool_name", "=", "$", "ip_pool_name", "->", "getIpPoolName", "(", ")", ";", "}", "else", "{", "$", "this", "->", "ip_pool_name", "=", "new", "IpPoolName", "(", "$", "ip_pool_name", ")", ";", "}", "}" ]
Add the IP pool name to a Mail object @param string|IpPoolName $ip_pool_name The IP Pool that you would like to send this email from
[ "Add", "the", "IP", "pool", "name", "to", "a", "Mail", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1555-L1563
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setBccSettings
public function setBccSettings($enable, $email = null) { if (!($this->mail_settings instanceof MailSettings)) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setBccSettings($enable, $email); }
php
public function setBccSettings($enable, $email = null) { if (!($this->mail_settings instanceof MailSettings)) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setBccSettings($enable, $email); }
[ "public", "function", "setBccSettings", "(", "$", "enable", ",", "$", "email", "=", "null", ")", "{", "if", "(", "!", "(", "$", "this", "->", "mail_settings", "instanceof", "MailSettings", ")", ")", "{", "$", "this", "->", "mail_settings", "=", "new", "MailSettings", "(", ")", ";", "}", "$", "this", "->", "mail_settings", "->", "setBccSettings", "(", "$", "enable", ",", "$", "email", ")", ";", "}" ]
Set the Bcc settings on a MailSettings object @param bool|BccSettings $enable A BccSettings object or a boolean to determine if this setting is active @param string|null $email The email address to be bcc'ed
[ "Set", "the", "Bcc", "settings", "on", "a", "MailSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1611-L1617
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.enableBypassListManagement
public function enableBypassListManagement() { if (!$this->mail_settings instanceof MailSettings) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setBypassListManagement(true); }
php
public function enableBypassListManagement() { if (!$this->mail_settings instanceof MailSettings) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setBypassListManagement(true); }
[ "public", "function", "enableBypassListManagement", "(", ")", "{", "if", "(", "!", "$", "this", "->", "mail_settings", "instanceof", "MailSettings", ")", "{", "$", "this", "->", "mail_settings", "=", "new", "MailSettings", "(", ")", ";", "}", "$", "this", "->", "mail_settings", "->", "setBypassListManagement", "(", "true", ")", ";", "}" ]
Enable bypass list management on a MailSettings object Allows you to bypass all unsubscribe groups and suppressions to ensure that the email is delivered to every single recipient. This should only be used in emergencies when it is absolutely necessary that every recipient receives your email.
[ "Enable", "bypass", "list", "management", "on", "a", "MailSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1627-L1633
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.disableBypassListManagement
public function disableBypassListManagement() { if (!($this->mail_settings instanceof MailSettings)) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setBypassListManagement(false); }
php
public function disableBypassListManagement() { if (!($this->mail_settings instanceof MailSettings)) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setBypassListManagement(false); }
[ "public", "function", "disableBypassListManagement", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "mail_settings", "instanceof", "MailSettings", ")", ")", "{", "$", "this", "->", "mail_settings", "=", "new", "MailSettings", "(", ")", ";", "}", "$", "this", "->", "mail_settings", "->", "setBypassListManagement", "(", "false", ")", ";", "}" ]
Disable bypass list management on a MailSettings object Allows you to bypass all unsubscribe groups and suppressions to ensure that the email is delivered to every single recipient. This should only be used in emergencies when it is absolutely necessary that every recipient receives your email.
[ "Disable", "bypass", "list", "management", "on", "a", "MailSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1643-L1649
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setFooter
public function setFooter($enable = null, $text = null, $html = null) { if (!$this->mail_settings instanceof MailSettings) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setFooter($enable, $text, $html); }
php
public function setFooter($enable = null, $text = null, $html = null) { if (!$this->mail_settings instanceof MailSettings) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setFooter($enable, $text, $html); }
[ "public", "function", "setFooter", "(", "$", "enable", "=", "null", ",", "$", "text", "=", "null", ",", "$", "html", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "mail_settings", "instanceof", "MailSettings", ")", "{", "$", "this", "->", "mail_settings", "=", "new", "MailSettings", "(", ")", ";", "}", "$", "this", "->", "mail_settings", "->", "setFooter", "(", "$", "enable", ",", "$", "text", ",", "$", "html", ")", ";", "}" ]
Set the Footer settings on a MailSettings object @param bool|Footer $enable A Footer object or a boolean to determine if this setting is active @param string|null $text The plain text content of the footer @param string|null $html The HTML content of the footer
[ "Set", "the", "Footer", "settings", "on", "a", "MailSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1659-L1665
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.enableSandBoxMode
public function enableSandBoxMode() { if (!($this->mail_settings instanceof MailSettings)) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setSandBoxMode(true); }
php
public function enableSandBoxMode() { if (!($this->mail_settings instanceof MailSettings)) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setSandBoxMode(true); }
[ "public", "function", "enableSandBoxMode", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "mail_settings", "instanceof", "MailSettings", ")", ")", "{", "$", "this", "->", "mail_settings", "=", "new", "MailSettings", "(", ")", ";", "}", "$", "this", "->", "mail_settings", "->", "setSandBoxMode", "(", "true", ")", ";", "}" ]
Enable sandbox mode on a MailSettings object This allows you to send a test email to ensure that your request body is valid and formatted correctly.
[ "Enable", "sandbox", "mode", "on", "a", "MailSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1673-L1679
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.disableSandBoxMode
public function disableSandBoxMode() { if (!($this->mail_settings instanceof MailSettings)) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setSandBoxMode(false); }
php
public function disableSandBoxMode() { if (!($this->mail_settings instanceof MailSettings)) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setSandBoxMode(false); }
[ "public", "function", "disableSandBoxMode", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "mail_settings", "instanceof", "MailSettings", ")", ")", "{", "$", "this", "->", "mail_settings", "=", "new", "MailSettings", "(", ")", ";", "}", "$", "this", "->", "mail_settings", "->", "setSandBoxMode", "(", "false", ")", ";", "}" ]
Disable sandbox mode on a MailSettings object This allows you to send a test email to ensure that your request body is valid and formatted correctly.
[ "Disable", "sandbox", "mode", "on", "a", "MailSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1687-L1693
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setSpamCheck
public function setSpamCheck($enable = null, $threshold = null, $post_to_url = null) { if (!$this->mail_settings instanceof MailSettings) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setSpamCheck($enable, $threshold, $post_to_url); }
php
public function setSpamCheck($enable = null, $threshold = null, $post_to_url = null) { if (!$this->mail_settings instanceof MailSettings) { $this->mail_settings = new MailSettings(); } $this->mail_settings->setSpamCheck($enable, $threshold, $post_to_url); }
[ "public", "function", "setSpamCheck", "(", "$", "enable", "=", "null", ",", "$", "threshold", "=", "null", ",", "$", "post_to_url", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "mail_settings", "instanceof", "MailSettings", ")", "{", "$", "this", "->", "mail_settings", "=", "new", "MailSettings", "(", ")", ";", "}", "$", "this", "->", "mail_settings", "->", "setSpamCheck", "(", "$", "enable", ",", "$", "threshold", ",", "$", "post_to_url", ")", ";", "}" ]
Set the spam check settings on a MailSettings object @param bool|SpamCheck $enable A SpamCheck object or a boolean to determine if this setting is active @param int|null $threshold The threshold used to determine if your content qualifies as spam on a scale from 1 to 10, with 10 being most strict, or most likely to be considered as spam @param string|null $post_to_url An Inbound Parse URL that you would like a copy of your email along with the spam report to be sent to
[ "Set", "the", "spam", "check", "settings", "on", "a", "MailSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1708-L1714
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.setGanalytics
public function setGanalytics( $enable = null, $utm_source = null, $utm_medium = null, $utm_term = null, $utm_content = null, $utm_campaign = null ) { if (!($this->tracking_settings instanceof TrackingSettings)) { $this->tracking_settings = new TrackingSettings(); } $this->tracking_settings->setGanalytics( $enable, $utm_source, $utm_medium, $utm_term, $utm_content, $utm_campaign ); }
php
public function setGanalytics( $enable = null, $utm_source = null, $utm_medium = null, $utm_term = null, $utm_content = null, $utm_campaign = null ) { if (!($this->tracking_settings instanceof TrackingSettings)) { $this->tracking_settings = new TrackingSettings(); } $this->tracking_settings->setGanalytics( $enable, $utm_source, $utm_medium, $utm_term, $utm_content, $utm_campaign ); }
[ "public", "function", "setGanalytics", "(", "$", "enable", "=", "null", ",", "$", "utm_source", "=", "null", ",", "$", "utm_medium", "=", "null", ",", "$", "utm_term", "=", "null", ",", "$", "utm_content", "=", "null", ",", "$", "utm_campaign", "=", "null", ")", "{", "if", "(", "!", "(", "$", "this", "->", "tracking_settings", "instanceof", "TrackingSettings", ")", ")", "{", "$", "this", "->", "tracking_settings", "=", "new", "TrackingSettings", "(", ")", ";", "}", "$", "this", "->", "tracking_settings", "->", "setGanalytics", "(", "$", "enable", ",", "$", "utm_source", ",", "$", "utm_medium", ",", "$", "utm_term", ",", "$", "utm_content", ",", "$", "utm_campaign", ")", ";", "}" ]
Set the Google anatlyics settings on a TrackingSettings object @param bool|Ganalytics $enable A Ganalytics object or a boolean to determine if this setting is active @param string|null $utm_source Name of the referrer source. (e.g. Google, SomeDomain.com, or Marketing Email) @param string|null $utm_medium Name of the marketing medium. (e.g. Email) @param string|null $utm_term Used to identify any paid keywords. @param string|null $utm_content Used to differentiate your campaign from advertisements @param string|null $utm_campaign The name of the campaign
[ "Set", "the", "Google", "anatlyics", "settings", "on", "a", "TrackingSettings", "object" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1848-L1867
train
sendgrid/sendgrid-php
lib/mail/Mail.php
Mail.jsonSerialize
public function jsonSerialize() { // Detect if we are using the new dynamic templates $template_id = $this->getTemplateId(); if ($template_id != null) { if (substr((string) $template_id->getTemplateId(), 0, 2) == "d-") { foreach ($this->personalization as $personalization) { $personalization->setHasDynamicTemplate(true); } } } return array_filter( [ 'personalizations' => $this->getPersonalizations(), 'from' => $this->getFrom(), 'reply_to' => $this->getReplyTo(), 'subject' => $this->getGlobalSubject(), 'content' => $this->getContents(), 'attachments' => $this->getAttachments(), 'template_id' => $this->getTemplateId(), 'sections' => $this->getSections(), 'headers' => $this->getGlobalHeaders(), 'categories' => $this->getCategories(), 'custom_args' => $this->getGlobalCustomArgs(), 'send_at' => $this->getGlobalSendAt(), 'batch_id' => $this->getBatchId(), 'asm' => $this->getASM(), 'ip_pool_name' => $this->getIpPoolName(), 'substitutions' => $this->getGlobalSubstitutions(), 'mail_settings' => $this->getMailSettings(), 'tracking_settings' => $this->getTrackingSettings() ], function ($value) { return $value !== null; } ) ?: null; }
php
public function jsonSerialize() { // Detect if we are using the new dynamic templates $template_id = $this->getTemplateId(); if ($template_id != null) { if (substr((string) $template_id->getTemplateId(), 0, 2) == "d-") { foreach ($this->personalization as $personalization) { $personalization->setHasDynamicTemplate(true); } } } return array_filter( [ 'personalizations' => $this->getPersonalizations(), 'from' => $this->getFrom(), 'reply_to' => $this->getReplyTo(), 'subject' => $this->getGlobalSubject(), 'content' => $this->getContents(), 'attachments' => $this->getAttachments(), 'template_id' => $this->getTemplateId(), 'sections' => $this->getSections(), 'headers' => $this->getGlobalHeaders(), 'categories' => $this->getCategories(), 'custom_args' => $this->getGlobalCustomArgs(), 'send_at' => $this->getGlobalSendAt(), 'batch_id' => $this->getBatchId(), 'asm' => $this->getASM(), 'ip_pool_name' => $this->getIpPoolName(), 'substitutions' => $this->getGlobalSubstitutions(), 'mail_settings' => $this->getMailSettings(), 'tracking_settings' => $this->getTrackingSettings() ], function ($value) { return $value !== null; } ) ?: null; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "// Detect if we are using the new dynamic templates", "$", "template_id", "=", "$", "this", "->", "getTemplateId", "(", ")", ";", "if", "(", "$", "template_id", "!=", "null", ")", "{", "if", "(", "substr", "(", "(", "string", ")", "$", "template_id", "->", "getTemplateId", "(", ")", ",", "0", ",", "2", ")", "==", "\"d-\"", ")", "{", "foreach", "(", "$", "this", "->", "personalization", "as", "$", "personalization", ")", "{", "$", "personalization", "->", "setHasDynamicTemplate", "(", "true", ")", ";", "}", "}", "}", "return", "array_filter", "(", "[", "'personalizations'", "=>", "$", "this", "->", "getPersonalizations", "(", ")", ",", "'from'", "=>", "$", "this", "->", "getFrom", "(", ")", ",", "'reply_to'", "=>", "$", "this", "->", "getReplyTo", "(", ")", ",", "'subject'", "=>", "$", "this", "->", "getGlobalSubject", "(", ")", ",", "'content'", "=>", "$", "this", "->", "getContents", "(", ")", ",", "'attachments'", "=>", "$", "this", "->", "getAttachments", "(", ")", ",", "'template_id'", "=>", "$", "this", "->", "getTemplateId", "(", ")", ",", "'sections'", "=>", "$", "this", "->", "getSections", "(", ")", ",", "'headers'", "=>", "$", "this", "->", "getGlobalHeaders", "(", ")", ",", "'categories'", "=>", "$", "this", "->", "getCategories", "(", ")", ",", "'custom_args'", "=>", "$", "this", "->", "getGlobalCustomArgs", "(", ")", ",", "'send_at'", "=>", "$", "this", "->", "getGlobalSendAt", "(", ")", ",", "'batch_id'", "=>", "$", "this", "->", "getBatchId", "(", ")", ",", "'asm'", "=>", "$", "this", "->", "getASM", "(", ")", ",", "'ip_pool_name'", "=>", "$", "this", "->", "getIpPoolName", "(", ")", ",", "'substitutions'", "=>", "$", "this", "->", "getGlobalSubstitutions", "(", ")", ",", "'mail_settings'", "=>", "$", "this", "->", "getMailSettings", "(", ")", ",", "'tracking_settings'", "=>", "$", "this", "->", "getTrackingSettings", "(", ")", "]", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", ";", "}", ")", "?", ":", "null", ";", "}" ]
Return an array representing a request object for the Twilio SendGrid API @return null|array
[ "Return", "an", "array", "representing", "a", "request", "object", "for", "the", "Twilio", "SendGrid", "API" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Mail.php#L1874-L1910
train
sendgrid/sendgrid-php
lib/mail/Ganalytics.php
Ganalytics.jsonSerialize
public function jsonSerialize() { return array_filter( [ 'enable' => $this->getEnable(), 'utm_source' => $this->getCampaignSource(), 'utm_medium' => $this->getCampaignMedium(), 'utm_term' => $this->getCampaignTerm(), 'utm_content' => $this->getCampaignContent(), 'utm_campaign' => $this->getCampaignName() ], function ($value) { return $value !== null; } ) ?: null; }
php
public function jsonSerialize() { return array_filter( [ 'enable' => $this->getEnable(), 'utm_source' => $this->getCampaignSource(), 'utm_medium' => $this->getCampaignMedium(), 'utm_term' => $this->getCampaignTerm(), 'utm_content' => $this->getCampaignContent(), 'utm_campaign' => $this->getCampaignName() ], function ($value) { return $value !== null; } ) ?: null; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "return", "array_filter", "(", "[", "'enable'", "=>", "$", "this", "->", "getEnable", "(", ")", ",", "'utm_source'", "=>", "$", "this", "->", "getCampaignSource", "(", ")", ",", "'utm_medium'", "=>", "$", "this", "->", "getCampaignMedium", "(", ")", ",", "'utm_term'", "=>", "$", "this", "->", "getCampaignTerm", "(", ")", ",", "'utm_content'", "=>", "$", "this", "->", "getCampaignContent", "(", ")", ",", "'utm_campaign'", "=>", "$", "this", "->", "getCampaignName", "(", ")", "]", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", ";", "}", ")", "?", ":", "null", ";", "}" ]
Return an array representing a Ganalytics object for the Twilio SendGrid API @return null|array
[ "Return", "an", "array", "representing", "a", "Ganalytics", "object", "for", "the", "Twilio", "SendGrid", "API" ]
37fa19d3ae019842f07a2a43e92ed0f566ad927d
https://github.com/sendgrid/sendgrid-php/blob/37fa19d3ae019842f07a2a43e92ed0f566ad927d/lib/mail/Ganalytics.php#L235-L250
train
mrclay/minify
lib/Minify/CSS/UriRewriter.php
Minify_CSS_UriRewriter.rewriteRelative
public static function rewriteRelative($uri, $realCurrentDir, $realDocRoot, $symlinks = array()) { // prepend path with current dir separator (OS-independent) $path = strtr($realCurrentDir, '/', DIRECTORY_SEPARATOR); $path .= DIRECTORY_SEPARATOR . strtr($uri, '/', DIRECTORY_SEPARATOR); self::$debugText .= "file-relative URI : {$uri}\n" . "path prepended : {$path}\n"; // "unresolve" a symlink back to doc root foreach ($symlinks as $link => $target) { if (0 === strpos($path, $target)) { // replace $target with $link $path = $link . substr($path, strlen($target)); self::$debugText .= "symlink unresolved : {$path}\n"; break; } } // strip doc root $path = substr($path, strlen($realDocRoot)); self::$debugText .= "docroot stripped : {$path}\n"; // fix to root-relative URI $uri = strtr($path, '/\\', '//'); $uri = self::removeDots($uri); self::$debugText .= "traversals removed : {$uri}\n\n"; return $uri; }
php
public static function rewriteRelative($uri, $realCurrentDir, $realDocRoot, $symlinks = array()) { // prepend path with current dir separator (OS-independent) $path = strtr($realCurrentDir, '/', DIRECTORY_SEPARATOR); $path .= DIRECTORY_SEPARATOR . strtr($uri, '/', DIRECTORY_SEPARATOR); self::$debugText .= "file-relative URI : {$uri}\n" . "path prepended : {$path}\n"; // "unresolve" a symlink back to doc root foreach ($symlinks as $link => $target) { if (0 === strpos($path, $target)) { // replace $target with $link $path = $link . substr($path, strlen($target)); self::$debugText .= "symlink unresolved : {$path}\n"; break; } } // strip doc root $path = substr($path, strlen($realDocRoot)); self::$debugText .= "docroot stripped : {$path}\n"; // fix to root-relative URI $uri = strtr($path, '/\\', '//'); $uri = self::removeDots($uri); self::$debugText .= "traversals removed : {$uri}\n\n"; return $uri; }
[ "public", "static", "function", "rewriteRelative", "(", "$", "uri", ",", "$", "realCurrentDir", ",", "$", "realDocRoot", ",", "$", "symlinks", "=", "array", "(", ")", ")", "{", "// prepend path with current dir separator (OS-independent)", "$", "path", "=", "strtr", "(", "$", "realCurrentDir", ",", "'/'", ",", "DIRECTORY_SEPARATOR", ")", ";", "$", "path", ".=", "DIRECTORY_SEPARATOR", ".", "strtr", "(", "$", "uri", ",", "'/'", ",", "DIRECTORY_SEPARATOR", ")", ";", "self", "::", "$", "debugText", ".=", "\"file-relative URI : {$uri}\\n\"", ".", "\"path prepended : {$path}\\n\"", ";", "// \"unresolve\" a symlink back to doc root", "foreach", "(", "$", "symlinks", "as", "$", "link", "=>", "$", "target", ")", "{", "if", "(", "0", "===", "strpos", "(", "$", "path", ",", "$", "target", ")", ")", "{", "// replace $target with $link", "$", "path", "=", "$", "link", ".", "substr", "(", "$", "path", ",", "strlen", "(", "$", "target", ")", ")", ";", "self", "::", "$", "debugText", ".=", "\"symlink unresolved : {$path}\\n\"", ";", "break", ";", "}", "}", "// strip doc root", "$", "path", "=", "substr", "(", "$", "path", ",", "strlen", "(", "$", "realDocRoot", ")", ")", ";", "self", "::", "$", "debugText", ".=", "\"docroot stripped : {$path}\\n\"", ";", "// fix to root-relative URI", "$", "uri", "=", "strtr", "(", "$", "path", ",", "'/\\\\'", ",", "'//'", ")", ";", "$", "uri", "=", "self", "::", "removeDots", "(", "$", "uri", ")", ";", "self", "::", "$", "debugText", ".=", "\"traversals removed : {$uri}\\n\\n\"", ";", "return", "$", "uri", ";", "}" ]
Get a root relative URI from a file relative URI <code> Minify_CSS_UriRewriter::rewriteRelative( '../img/hello.gif' , '/home/user/www/css' // path of CSS file , '/home/user/www' // doc root ); // returns '/img/hello.gif' // example where static files are stored in a symlinked directory Minify_CSS_UriRewriter::rewriteRelative( 'hello.gif' , '/var/staticFiles/theme' , '/home/user/www' , array('/home/user/www/static' => '/var/staticFiles') ); // returns '/static/theme/hello.gif' </code> @param string $uri file relative URI @param string $realCurrentDir realpath of the current file's directory. @param string $realDocRoot realpath of the site document root. @param array $symlinks (default = array()) If the file is stored in a symlink-ed directory, provide an array of link paths to real target paths, where the link paths "appear" to be within the document root. E.g.: <code> array('/home/foo/www/not/real/path' => '/real/target/path') // unix array('C:\\htdocs\\not\\real' => 'D:\\real\\target\\path') // Windows </code> @return string
[ "Get", "a", "root", "relative", "URI", "from", "a", "file", "relative", "URI" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/CSS/UriRewriter.php#L153-L185
train
mrclay/minify
lib/Minify/SourceSet.php
Minify_SourceSet.getDigest
public static function getDigest($sources) { $info = array(); foreach ($sources as $source) { $info[] = array( $source->getId(), $source->getMinifier(), $source->getMinifierOptions() ); } return md5(serialize($info)); }
php
public static function getDigest($sources) { $info = array(); foreach ($sources as $source) { $info[] = array( $source->getId(), $source->getMinifier(), $source->getMinifierOptions() ); } return md5(serialize($info)); }
[ "public", "static", "function", "getDigest", "(", "$", "sources", ")", "{", "$", "info", "=", "array", "(", ")", ";", "foreach", "(", "$", "sources", "as", "$", "source", ")", "{", "$", "info", "[", "]", "=", "array", "(", "$", "source", "->", "getId", "(", ")", ",", "$", "source", "->", "getMinifier", "(", ")", ",", "$", "source", "->", "getMinifierOptions", "(", ")", ")", ";", "}", "return", "md5", "(", "serialize", "(", "$", "info", ")", ")", ";", "}" ]
Get unique string for a set of sources @param Minify_SourceInterface[] $sources Minify_Source instances @return string
[ "Get", "unique", "string", "for", "a", "set", "of", "sources" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/SourceSet.php#L20-L30
train
mrclay/minify
lib/Minify/Build.php
Minify_Build.uri
public function uri($uri, $forceAmpersand = false) { $sep = ($forceAmpersand || strpos($uri, '?') !== false) ? self::$ampersand : '?'; return "{$uri}{$sep}{$this->lastModified}"; }
php
public function uri($uri, $forceAmpersand = false) { $sep = ($forceAmpersand || strpos($uri, '?') !== false) ? self::$ampersand : '?'; return "{$uri}{$sep}{$this->lastModified}"; }
[ "public", "function", "uri", "(", "$", "uri", ",", "$", "forceAmpersand", "=", "false", ")", "{", "$", "sep", "=", "(", "$", "forceAmpersand", "||", "strpos", "(", "$", "uri", ",", "'?'", ")", "!==", "false", ")", "?", "self", "::", "$", "ampersand", ":", "'?'", ";", "return", "\"{$uri}{$sep}{$this->lastModified}\"", ";", "}" ]
Get a time-stamped URI <code> echo $b->uri('/site.js'); // outputs "/site.js?1678242" echo $b->uri('/scriptaculous.js?load=effects'); // outputs "/scriptaculous.js?load=effects&amp1678242" </code> @param string $uri @param boolean $forceAmpersand (default = false) Force the use of ampersand to append the timestamp to the URI. @return string
[ "Get", "a", "time", "-", "stamped", "URI" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Build.php#L71-L76
train
mrclay/minify
lib/Minify/Cache/XCache.php
Minify_Cache_XCache.getSize
public function getSize($id) { if (! $this->_fetch($id)) { return false; } if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) { return mb_strlen($this->_data, '8bit'); } else { return strlen($this->_data); } }
php
public function getSize($id) { if (! $this->_fetch($id)) { return false; } if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) { return mb_strlen($this->_data, '8bit'); } else { return strlen($this->_data); } }
[ "public", "function", "getSize", "(", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "_fetch", "(", "$", "id", ")", ")", "{", "return", "false", ";", "}", "if", "(", "function_exists", "(", "'mb_strlen'", ")", "&&", "(", "(", "int", ")", "ini_get", "(", "'mbstring.func_overload'", ")", "&", "2", ")", ")", "{", "return", "mb_strlen", "(", "$", "this", "->", "_data", ",", "'8bit'", ")", ";", "}", "else", "{", "return", "strlen", "(", "$", "this", "->", "_data", ")", ";", "}", "}" ]
Get the size of a cache entry @param string $id cache id @return int size in bytes
[ "Get", "the", "size", "of", "a", "cache", "entry" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Cache/XCache.php#L53-L64
train
mrclay/minify
lib/Minify/Cache/XCache.php
Minify_Cache_XCache._fetch
private function _fetch($id) { if ($this->_id === $id) { return true; } $ret = xcache_get($id); if (false === $ret) { $this->_id = null; return false; } list($this->_lm, $this->_data) = explode('|', $ret, 2); $this->_id = $id; return true; }
php
private function _fetch($id) { if ($this->_id === $id) { return true; } $ret = xcache_get($id); if (false === $ret) { $this->_id = null; return false; } list($this->_lm, $this->_data) = explode('|', $ret, 2); $this->_id = $id; return true; }
[ "private", "function", "_fetch", "(", "$", "id", ")", "{", "if", "(", "$", "this", "->", "_id", "===", "$", "id", ")", "{", "return", "true", ";", "}", "$", "ret", "=", "xcache_get", "(", "$", "id", ")", ";", "if", "(", "false", "===", "$", "ret", ")", "{", "$", "this", "->", "_id", "=", "null", ";", "return", "false", ";", "}", "list", "(", "$", "this", "->", "_lm", ",", "$", "this", "->", "_data", ")", "=", "explode", "(", "'|'", ",", "$", "ret", ",", "2", ")", ";", "$", "this", "->", "_id", "=", "$", "id", ";", "return", "true", ";", "}" ]
Fetch data and timestamp from xcache, store in instance @param string $id @return bool success
[ "Fetch", "data", "and", "timestamp", "from", "xcache", "store", "in", "instance" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Cache/XCache.php#L112-L129
train
mrclay/minify
lib/Minify/Controller/Page.php
Minify_Controller_Page.createConfiguration
public function createConfiguration(array $options) { if (isset($options['file'])) { $sourceSpec = array( 'filepath' => $options['file'] ); $f = $options['file']; } else { // strip controller options $sourceSpec = array( 'content' => $options['content'], 'id' => $options['id'], ); $f = $options['id']; unset($options['content'], $options['id']); } // something like "builder,index.php" or "directory,file.html" $selectionId = strtr(substr($f, 1 + strlen(dirname(dirname($f)))), '/\\', ',,'); if (isset($options['minifyAll'])) { // this will be the 2nd argument passed to Minify_HTML::minify() $sourceSpec['minifyOptions'] = array( 'cssMinifier' => array('Minify_CSSmin', 'minify'), 'jsMinifier' => array('JSMin\\JSMin', 'minify'), ); unset($options['minifyAll']); } $sourceSpec['contentType'] = Minify::TYPE_HTML; $sources[] = new Minify_Source($sourceSpec); return new Minify_ServeConfiguration($options, $sources, $selectionId); }
php
public function createConfiguration(array $options) { if (isset($options['file'])) { $sourceSpec = array( 'filepath' => $options['file'] ); $f = $options['file']; } else { // strip controller options $sourceSpec = array( 'content' => $options['content'], 'id' => $options['id'], ); $f = $options['id']; unset($options['content'], $options['id']); } // something like "builder,index.php" or "directory,file.html" $selectionId = strtr(substr($f, 1 + strlen(dirname(dirname($f)))), '/\\', ',,'); if (isset($options['minifyAll'])) { // this will be the 2nd argument passed to Minify_HTML::minify() $sourceSpec['minifyOptions'] = array( 'cssMinifier' => array('Minify_CSSmin', 'minify'), 'jsMinifier' => array('JSMin\\JSMin', 'minify'), ); unset($options['minifyAll']); } $sourceSpec['contentType'] = Minify::TYPE_HTML; $sources[] = new Minify_Source($sourceSpec); return new Minify_ServeConfiguration($options, $sources, $selectionId); }
[ "public", "function", "createConfiguration", "(", "array", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'file'", "]", ")", ")", "{", "$", "sourceSpec", "=", "array", "(", "'filepath'", "=>", "$", "options", "[", "'file'", "]", ")", ";", "$", "f", "=", "$", "options", "[", "'file'", "]", ";", "}", "else", "{", "// strip controller options", "$", "sourceSpec", "=", "array", "(", "'content'", "=>", "$", "options", "[", "'content'", "]", ",", "'id'", "=>", "$", "options", "[", "'id'", "]", ",", ")", ";", "$", "f", "=", "$", "options", "[", "'id'", "]", ";", "unset", "(", "$", "options", "[", "'content'", "]", ",", "$", "options", "[", "'id'", "]", ")", ";", "}", "// something like \"builder,index.php\" or \"directory,file.html\"", "$", "selectionId", "=", "strtr", "(", "substr", "(", "$", "f", ",", "1", "+", "strlen", "(", "dirname", "(", "dirname", "(", "$", "f", ")", ")", ")", ")", ",", "'/\\\\'", ",", "',,'", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'minifyAll'", "]", ")", ")", "{", "// this will be the 2nd argument passed to Minify_HTML::minify()", "$", "sourceSpec", "[", "'minifyOptions'", "]", "=", "array", "(", "'cssMinifier'", "=>", "array", "(", "'Minify_CSSmin'", ",", "'minify'", ")", ",", "'jsMinifier'", "=>", "array", "(", "'JSMin\\\\JSMin'", ",", "'minify'", ")", ",", ")", ";", "unset", "(", "$", "options", "[", "'minifyAll'", "]", ")", ";", "}", "$", "sourceSpec", "[", "'contentType'", "]", "=", "Minify", "::", "TYPE_HTML", ";", "$", "sources", "[", "]", "=", "new", "Minify_Source", "(", "$", "sourceSpec", ")", ";", "return", "new", "Minify_ServeConfiguration", "(", "$", "options", ",", "$", "sources", ",", "$", "selectionId", ")", ";", "}" ]
Set up source of HTML content @param array $options controller and Minify options @return array Minify options Controller options: 'content': (required) HTML markup 'id': (required) id of page (string for use in server-side caching) 'lastModifiedTime': timestamp of when this content changed. This is recommended to allow both server and client-side caching. 'minifyAll': should all CSS and Javascript blocks be individually minified? (default false)
[ "Set", "up", "source", "of", "HTML", "content" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Controller/Page.php#L35-L67
train
mrclay/minify
lib/Minify/LessCssSource.php
Minify_LessCssSource.getCache
private function getCache() { // cache for single run // so that getLastModified and getContent in single request do not add additional cache roundtrips (i.e memcache) if (isset($this->parsed)) { return $this->parsed; } // check from cache first $cache = null; $cacheId = $this->getCacheId(); if ($this->cache->isValid($cacheId, 0)) { if ($cache = $this->cache->fetch($cacheId)) { $cache = unserialize($cache); } } $less = $this->getCompiler(); $input = $cache ? $cache : $this->filepath; $cache = $less->cachedCompile($input); if (!is_array($input) || $cache['updated'] > $input['updated']) { $cache['lastModified'] = $this->getMaxLastModified($cache); $this->cache->store($cacheId, serialize($cache)); } return $this->parsed = $cache; }
php
private function getCache() { // cache for single run // so that getLastModified and getContent in single request do not add additional cache roundtrips (i.e memcache) if (isset($this->parsed)) { return $this->parsed; } // check from cache first $cache = null; $cacheId = $this->getCacheId(); if ($this->cache->isValid($cacheId, 0)) { if ($cache = $this->cache->fetch($cacheId)) { $cache = unserialize($cache); } } $less = $this->getCompiler(); $input = $cache ? $cache : $this->filepath; $cache = $less->cachedCompile($input); if (!is_array($input) || $cache['updated'] > $input['updated']) { $cache['lastModified'] = $this->getMaxLastModified($cache); $this->cache->store($cacheId, serialize($cache)); } return $this->parsed = $cache; }
[ "private", "function", "getCache", "(", ")", "{", "// cache for single run", "// so that getLastModified and getContent in single request do not add additional cache roundtrips (i.e memcache)", "if", "(", "isset", "(", "$", "this", "->", "parsed", ")", ")", "{", "return", "$", "this", "->", "parsed", ";", "}", "// check from cache first", "$", "cache", "=", "null", ";", "$", "cacheId", "=", "$", "this", "->", "getCacheId", "(", ")", ";", "if", "(", "$", "this", "->", "cache", "->", "isValid", "(", "$", "cacheId", ",", "0", ")", ")", "{", "if", "(", "$", "cache", "=", "$", "this", "->", "cache", "->", "fetch", "(", "$", "cacheId", ")", ")", "{", "$", "cache", "=", "unserialize", "(", "$", "cache", ")", ";", "}", "}", "$", "less", "=", "$", "this", "->", "getCompiler", "(", ")", ";", "$", "input", "=", "$", "cache", "?", "$", "cache", ":", "$", "this", "->", "filepath", ";", "$", "cache", "=", "$", "less", "->", "cachedCompile", "(", "$", "input", ")", ";", "if", "(", "!", "is_array", "(", "$", "input", ")", "||", "$", "cache", "[", "'updated'", "]", ">", "$", "input", "[", "'updated'", "]", ")", "{", "$", "cache", "[", "'lastModified'", "]", "=", "$", "this", "->", "getMaxLastModified", "(", "$", "cache", ")", ";", "$", "this", "->", "cache", "->", "store", "(", "$", "cacheId", ",", "serialize", "(", "$", "cache", ")", ")", ";", "}", "return", "$", "this", "->", "parsed", "=", "$", "cache", ";", "}" ]
Get lessphp cache object @return array
[ "Get", "lessphp", "cache", "object" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/LessCssSource.php#L56-L83
train
mrclay/minify
lib/Minify/CommentPreserver.php
Minify_CommentPreserver._nextComment
private static function _nextComment($in) { if (false === ($start = strpos($in, '/*!')) || false === ($end = strpos($in, '*/', $start + 3))) { return array($in, false, false); } $beforeComment = substr($in, 0, $start); $comment = self::$prepend . '/*!' . substr($in, $start + 3, $end - $start - 1) . self::$append; $endChars = (strlen($in) - $end - 2); $afterComment = (0 === $endChars) ? '' : substr($in, -$endChars); return array($beforeComment, $comment, $afterComment); }
php
private static function _nextComment($in) { if (false === ($start = strpos($in, '/*!')) || false === ($end = strpos($in, '*/', $start + 3))) { return array($in, false, false); } $beforeComment = substr($in, 0, $start); $comment = self::$prepend . '/*!' . substr($in, $start + 3, $end - $start - 1) . self::$append; $endChars = (strlen($in) - $end - 2); $afterComment = (0 === $endChars) ? '' : substr($in, -$endChars); return array($beforeComment, $comment, $afterComment); }
[ "private", "static", "function", "_nextComment", "(", "$", "in", ")", "{", "if", "(", "false", "===", "(", "$", "start", "=", "strpos", "(", "$", "in", ",", "'/*!'", ")", ")", "||", "false", "===", "(", "$", "end", "=", "strpos", "(", "$", "in", ",", "'*/'", ",", "$", "start", "+", "3", ")", ")", ")", "{", "return", "array", "(", "$", "in", ",", "false", ",", "false", ")", ";", "}", "$", "beforeComment", "=", "substr", "(", "$", "in", ",", "0", ",", "$", "start", ")", ";", "$", "comment", "=", "self", "::", "$", "prepend", ".", "'/*!'", ".", "substr", "(", "$", "in", ",", "$", "start", "+", "3", ",", "$", "end", "-", "$", "start", "-", "1", ")", ".", "self", "::", "$", "append", ";", "$", "endChars", "=", "(", "strlen", "(", "$", "in", ")", "-", "$", "end", "-", "2", ")", ";", "$", "afterComment", "=", "(", "0", "===", "$", "endChars", ")", "?", "''", ":", "substr", "(", "$", "in", ",", "-", "$", "endChars", ")", ";", "return", "array", "(", "$", "beforeComment", ",", "$", "comment", ",", "$", "afterComment", ")", ";", "}" ]
Extract comments that YUI Compressor preserves. @param string $in input @return array 3 elements are returned. If a YUI comment is found, the 2nd element is the comment and the 1st and 3rd are the surrounding strings. If no comment is found, the entire string is returned as the 1st element and the other two are false.
[ "Extract", "comments", "that", "YUI", "Compressor", "preserves", "." ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/CommentPreserver.php#L73-L86
train
mrclay/minify
lib/MrClay/Cli.php
Cli.getErrorReport
public function getErrorReport() { if (empty($this->errors)) { return ''; } $r = "Some arguments did not pass validation:\n"; foreach ($this->errors as $letter => $arr) { $r .= " $letter : " . implode(', ', $arr) . "\n"; } $r .= "\n"; return $r; }
php
public function getErrorReport() { if (empty($this->errors)) { return ''; } $r = "Some arguments did not pass validation:\n"; foreach ($this->errors as $letter => $arr) { $r .= " $letter : " . implode(', ', $arr) . "\n"; } $r .= "\n"; return $r; }
[ "public", "function", "getErrorReport", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "errors", ")", ")", "{", "return", "''", ";", "}", "$", "r", "=", "\"Some arguments did not pass validation:\\n\"", ";", "foreach", "(", "$", "this", "->", "errors", "as", "$", "letter", "=>", "$", "arr", ")", "{", "$", "r", ".=", "\" $letter : \"", ".", "implode", "(", "', '", ",", "$", "arr", ")", ".", "\"\\n\"", ";", "}", "$", "r", ".=", "\"\\n\"", ";", "return", "$", "r", ";", "}" ]
Get a short list of errors with options @return string
[ "Get", "a", "short", "list", "of", "errors", "with", "options" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/MrClay/Cli.php#L286-L298
train
mrclay/minify
lib/MrClay/Cli.php
Cli.openInput
public function openInput() { if (null === $this->_stdin) { return STDIN; } else { $this->_stdin = fopen($this->_stdin, 'rb'); return $this->_stdin; } }
php
public function openInput() { if (null === $this->_stdin) { return STDIN; } else { $this->_stdin = fopen($this->_stdin, 'rb'); return $this->_stdin; } }
[ "public", "function", "openInput", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "_stdin", ")", "{", "return", "STDIN", ";", "}", "else", "{", "$", "this", "->", "_stdin", "=", "fopen", "(", "$", "this", "->", "_stdin", ",", "'rb'", ")", ";", "return", "$", "this", "->", "_stdin", ";", "}", "}" ]
Get resource of open input stream. May be STDIN or a file pointer to the file specified by an option with 'STDIN'. @return resource
[ "Get", "resource", "of", "open", "input", "stream", ".", "May", "be", "STDIN", "or", "a", "file", "pointer", "to", "the", "file", "specified", "by", "an", "option", "with", "STDIN", "." ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/MrClay/Cli.php#L337-L346
train
mrclay/minify
lib/MrClay/Cli.php
Cli.openOutput
public function openOutput() { if (null === $this->_stdout) { return STDOUT; } else { $this->_stdout = fopen($this->_stdout, 'wb'); return $this->_stdout; } }
php
public function openOutput() { if (null === $this->_stdout) { return STDOUT; } else { $this->_stdout = fopen($this->_stdout, 'wb'); return $this->_stdout; } }
[ "public", "function", "openOutput", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "_stdout", ")", "{", "return", "STDOUT", ";", "}", "else", "{", "$", "this", "->", "_stdout", "=", "fopen", "(", "$", "this", "->", "_stdout", ",", "'wb'", ")", ";", "return", "$", "this", "->", "_stdout", ";", "}", "}" ]
Get resource of open output stream. May be STDOUT or a file pointer to the file specified by an option with 'STDOUT'. The file will be truncated to 0 bytes on opening. @return resource
[ "Get", "resource", "of", "open", "output", "stream", ".", "May", "be", "STDOUT", "or", "a", "file", "pointer", "to", "the", "file", "specified", "by", "an", "option", "with", "STDOUT", ".", "The", "file", "will", "be", "truncated", "to", "0", "bytes", "on", "opening", "." ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/MrClay/Cli.php#L362-L371
train
mrclay/minify
lib/HTTP/ConditionalGet.php
HTTP_ConditionalGet.check
public static function check($lastModifiedTime = null, $isPublic = false, $options = array()) { if (null !== $lastModifiedTime) { $options['lastModifiedTime'] = (int)$lastModifiedTime; } $options['isPublic'] = (bool)$isPublic; $cg = new HTTP_ConditionalGet($options); $cg->sendHeaders(); if ($cg->cacheIsValid) { exit(); } }
php
public static function check($lastModifiedTime = null, $isPublic = false, $options = array()) { if (null !== $lastModifiedTime) { $options['lastModifiedTime'] = (int)$lastModifiedTime; } $options['isPublic'] = (bool)$isPublic; $cg = new HTTP_ConditionalGet($options); $cg->sendHeaders(); if ($cg->cacheIsValid) { exit(); } }
[ "public", "static", "function", "check", "(", "$", "lastModifiedTime", "=", "null", ",", "$", "isPublic", "=", "false", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "null", "!==", "$", "lastModifiedTime", ")", "{", "$", "options", "[", "'lastModifiedTime'", "]", "=", "(", "int", ")", "$", "lastModifiedTime", ";", "}", "$", "options", "[", "'isPublic'", "]", "=", "(", "bool", ")", "$", "isPublic", ";", "$", "cg", "=", "new", "HTTP_ConditionalGet", "(", "$", "options", ")", ";", "$", "cg", "->", "sendHeaders", "(", ")", ";", "if", "(", "$", "cg", "->", "cacheIsValid", ")", "{", "exit", "(", ")", ";", "}", "}" ]
Exit if the client's cache is valid for this resource This is a convenience method for common use of the class @param int $lastModifiedTime if given, both ETag AND Last-Modified headers will be sent with content. This is recommended. @param bool $isPublic (default false) if true, the Cache-Control header will contain "public", allowing proxies to cache the content. Otherwise "private" will be sent, allowing only browser caching. @param array $options (default empty) additional options for constructor
[ "Exit", "if", "the", "client", "s", "cache", "is", "valid", "for", "this", "resource" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/HTTP/ConditionalGet.php#L237-L248
train
mrclay/minify
lib/HTTP/ConditionalGet.php
HTTP_ConditionalGet._isCacheValid
protected function _isCacheValid() { if (null === $this->_etag) { // lmTime is copied to ETag, so this condition implies that the // server sent neither ETag nor Last-Modified, so the client can't // possibly has a valid cache. return false; } $isValid = ($this->resourceMatchedEtag() || $this->resourceNotModified()); if ($isValid) { $this->_headers['_responseCode'] = 'HTTP/1.0 304 Not Modified'; } return $isValid; }
php
protected function _isCacheValid() { if (null === $this->_etag) { // lmTime is copied to ETag, so this condition implies that the // server sent neither ETag nor Last-Modified, so the client can't // possibly has a valid cache. return false; } $isValid = ($this->resourceMatchedEtag() || $this->resourceNotModified()); if ($isValid) { $this->_headers['_responseCode'] = 'HTTP/1.0 304 Not Modified'; } return $isValid; }
[ "protected", "function", "_isCacheValid", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "_etag", ")", "{", "// lmTime is copied to ETag, so this condition implies that the", "// server sent neither ETag nor Last-Modified, so the client can't", "// possibly has a valid cache.", "return", "false", ";", "}", "$", "isValid", "=", "(", "$", "this", "->", "resourceMatchedEtag", "(", ")", "||", "$", "this", "->", "resourceNotModified", "(", ")", ")", ";", "if", "(", "$", "isValid", ")", "{", "$", "this", "->", "_headers", "[", "'_responseCode'", "]", "=", "'HTTP/1.0 304 Not Modified'", ";", "}", "return", "$", "isValid", ";", "}" ]
Determine validity of client cache and queue 304 header if valid @return bool
[ "Determine", "validity", "of", "client", "cache", "and", "queue", "304", "header", "if", "valid" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/HTTP/ConditionalGet.php#L296-L310
train
mrclay/minify
lib/Minify/Cache/File.php
Minify_Cache_File.store
public function store($id, $data) { $flag = $this->locking ? LOCK_EX : null; $file = $this->path . '/' . $id; if (! @file_put_contents($file, $data, $flag)) { $this->logger->warning("Minify_Cache_File: Write failed to '$file'"); } // write control if ($data !== $this->fetch($id)) { @unlink($file); $this->logger->warning("Minify_Cache_File: Post-write read failed for '$file'"); return false; } return true; }
php
public function store($id, $data) { $flag = $this->locking ? LOCK_EX : null; $file = $this->path . '/' . $id; if (! @file_put_contents($file, $data, $flag)) { $this->logger->warning("Minify_Cache_File: Write failed to '$file'"); } // write control if ($data !== $this->fetch($id)) { @unlink($file); $this->logger->warning("Minify_Cache_File: Post-write read failed for '$file'"); return false; } return true; }
[ "public", "function", "store", "(", "$", "id", ",", "$", "data", ")", "{", "$", "flag", "=", "$", "this", "->", "locking", "?", "LOCK_EX", ":", "null", ";", "$", "file", "=", "$", "this", "->", "path", ".", "'/'", ".", "$", "id", ";", "if", "(", "!", "@", "file_put_contents", "(", "$", "file", ",", "$", "data", ",", "$", "flag", ")", ")", "{", "$", "this", "->", "logger", "->", "warning", "(", "\"Minify_Cache_File: Write failed to '$file'\"", ")", ";", "}", "// write control", "if", "(", "$", "data", "!==", "$", "this", "->", "fetch", "(", "$", "id", ")", ")", "{", "@", "unlink", "(", "$", "file", ")", ";", "$", "this", "->", "logger", "->", "warning", "(", "\"Minify_Cache_File: Post-write read failed for '$file'\"", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Write data to cache. @param string $id cache id (e.g. a filename) @param string $data @return bool success
[ "Write", "data", "to", "cache", "." ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Cache/File.php#L55-L73
train
mrclay/minify
lib/Minify/Cache/File.php
Minify_Cache_File.isValid
public function isValid($id, $srcMtime) { $file = $this->path . '/' . $id; return (is_file($file) && (filemtime($file) >= $srcMtime)); }
php
public function isValid($id, $srcMtime) { $file = $this->path . '/' . $id; return (is_file($file) && (filemtime($file) >= $srcMtime)); }
[ "public", "function", "isValid", "(", "$", "id", ",", "$", "srcMtime", ")", "{", "$", "file", "=", "$", "this", "->", "path", ".", "'/'", ".", "$", "id", ";", "return", "(", "is_file", "(", "$", "file", ")", "&&", "(", "filemtime", "(", "$", "file", ")", ">=", "$", "srcMtime", ")", ")", ";", "}" ]
Does a valid cache entry exist? @param string $id cache id (e.g. a filename) @param int $srcMtime mtime of the original source file(s) @return bool exists
[ "Does", "a", "valid", "cache", "entry", "exist?" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Cache/File.php#L96-L101
train
mrclay/minify
lib/Minify/Cache/File.php
Minify_Cache_File.display
public function display($id) { if (!$this->locking) { readfile($this->path . '/' . $id); return; } $fp = fopen($this->path . '/' . $id, 'rb'); flock($fp, LOCK_SH); fpassthru($fp); flock($fp, LOCK_UN); fclose($fp); }
php
public function display($id) { if (!$this->locking) { readfile($this->path . '/' . $id); return; } $fp = fopen($this->path . '/' . $id, 'rb'); flock($fp, LOCK_SH); fpassthru($fp); flock($fp, LOCK_UN); fclose($fp); }
[ "public", "function", "display", "(", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "locking", ")", "{", "readfile", "(", "$", "this", "->", "path", ".", "'/'", ".", "$", "id", ")", ";", "return", ";", "}", "$", "fp", "=", "fopen", "(", "$", "this", "->", "path", ".", "'/'", ".", "$", "id", ",", "'rb'", ")", ";", "flock", "(", "$", "fp", ",", "LOCK_SH", ")", ";", "fpassthru", "(", "$", "fp", ")", ";", "flock", "(", "$", "fp", ",", "LOCK_UN", ")", ";", "fclose", "(", "$", "fp", ")", ";", "}" ]
Send the cached content to output @param string $id cache id (e.g. a filename)
[ "Send", "the", "cached", "content", "to", "output" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Cache/File.php#L108-L121
train
mrclay/minify
lib/Minify/Cache/File.php
Minify_Cache_File.fetch
public function fetch($id) { if (!$this->locking) { return file_get_contents($this->path . '/' . $id); } $fp = fopen($this->path . '/' . $id, 'rb'); if (!$fp) { return false; } flock($fp, LOCK_SH); $ret = stream_get_contents($fp); flock($fp, LOCK_UN); fclose($fp); return $ret; }
php
public function fetch($id) { if (!$this->locking) { return file_get_contents($this->path . '/' . $id); } $fp = fopen($this->path . '/' . $id, 'rb'); if (!$fp) { return false; } flock($fp, LOCK_SH); $ret = stream_get_contents($fp); flock($fp, LOCK_UN); fclose($fp); return $ret; }
[ "public", "function", "fetch", "(", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "locking", ")", "{", "return", "file_get_contents", "(", "$", "this", "->", "path", ".", "'/'", ".", "$", "id", ")", ";", "}", "$", "fp", "=", "fopen", "(", "$", "this", "->", "path", ".", "'/'", ".", "$", "id", ",", "'rb'", ")", ";", "if", "(", "!", "$", "fp", ")", "{", "return", "false", ";", "}", "flock", "(", "$", "fp", ",", "LOCK_SH", ")", ";", "$", "ret", "=", "stream_get_contents", "(", "$", "fp", ")", ";", "flock", "(", "$", "fp", ",", "LOCK_UN", ")", ";", "fclose", "(", "$", "fp", ")", ";", "return", "$", "ret", ";", "}" ]
Fetch the cached content @param string $id cache id (e.g. a filename) @return string
[ "Fetch", "the", "cached", "content" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Cache/File.php#L130-L147
train
mrclay/minify
lib/Minify/NailgunClosureCompiler.php
Minify_NailgunClosureCompiler.getServerCommandLine
protected function getServerCommandLine() { $this->checkJar(self::$ngJarFile); $this->checkJar(self::$jarFile); $classPath = array( self::$ngJarFile, self::$jarFile, ); // The command for the server that should show up in the process list $server = array( self::$javaExecutable, '-server', '-cp', implode(':', $classPath), self::NG_SERVER, ); return $server; }
php
protected function getServerCommandLine() { $this->checkJar(self::$ngJarFile); $this->checkJar(self::$jarFile); $classPath = array( self::$ngJarFile, self::$jarFile, ); // The command for the server that should show up in the process list $server = array( self::$javaExecutable, '-server', '-cp', implode(':', $classPath), self::NG_SERVER, ); return $server; }
[ "protected", "function", "getServerCommandLine", "(", ")", "{", "$", "this", "->", "checkJar", "(", "self", "::", "$", "ngJarFile", ")", ";", "$", "this", "->", "checkJar", "(", "self", "::", "$", "jarFile", ")", ";", "$", "classPath", "=", "array", "(", "self", "::", "$", "ngJarFile", ",", "self", "::", "$", "jarFile", ",", ")", ";", "// The command for the server that should show up in the process list", "$", "server", "=", "array", "(", "self", "::", "$", "javaExecutable", ",", "'-server'", ",", "'-cp'", ",", "implode", "(", "':'", ",", "$", "classPath", ")", ",", "self", "::", "NG_SERVER", ",", ")", ";", "return", "$", "server", ";", "}" ]
Get command to launch NailGun server. @return array
[ "Get", "command", "to", "launch", "NailGun", "server", "." ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/NailgunClosureCompiler.php#L52-L71
train
mrclay/minify
lib/Minify/Env.php
Minify_Env.normalizePath
public function normalizePath($path) { $realpath = realpath($path); if ($realpath) { $path = $realpath; } $path = str_replace('\\', '/', $path); $path = rtrim($path, '/'); if (substr($path, 1, 1) === ':') { $path = lcfirst($path); } return $path; }
php
public function normalizePath($path) { $realpath = realpath($path); if ($realpath) { $path = $realpath; } $path = str_replace('\\', '/', $path); $path = rtrim($path, '/'); if (substr($path, 1, 1) === ':') { $path = lcfirst($path); } return $path; }
[ "public", "function", "normalizePath", "(", "$", "path", ")", "{", "$", "realpath", "=", "realpath", "(", "$", "path", ")", ";", "if", "(", "$", "realpath", ")", "{", "$", "path", "=", "$", "realpath", ";", "}", "$", "path", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "path", ")", ";", "$", "path", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ";", "if", "(", "substr", "(", "$", "path", ",", "1", ",", "1", ")", "===", "':'", ")", "{", "$", "path", "=", "lcfirst", "(", "$", "path", ")", ";", "}", "return", "$", "path", ";", "}" ]
turn windows-style slashes into unix-style, remove trailing slash and lowercase drive letter @param string $path absolute path @return string
[ "turn", "windows", "-", "style", "slashes", "into", "unix", "-", "style", "remove", "trailing", "slash", "and", "lowercase", "drive", "letter" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Env.php#L89-L103
train
mrclay/minify
lib/Minify/Controller/Files.php
Minify_Controller_Files.createConfiguration
public function createConfiguration(array $options) { // strip controller options $files = $options['files']; // if $files is a single object, casting will break it if (is_object($files)) { $files = array($files); } elseif (! is_array($files)) { $files = (array)$files; } unset($options['files']); $sources = array(); foreach ($files as $file) { try { $sources[] = $this->sourceFactory->makeSource($file); } catch (Minify_Source_FactoryException $e) { $this->logger->error($e->getMessage()); return new Minify_ServeConfiguration($options); } } return new Minify_ServeConfiguration($options, $sources); }
php
public function createConfiguration(array $options) { // strip controller options $files = $options['files']; // if $files is a single object, casting will break it if (is_object($files)) { $files = array($files); } elseif (! is_array($files)) { $files = (array)$files; } unset($options['files']); $sources = array(); foreach ($files as $file) { try { $sources[] = $this->sourceFactory->makeSource($file); } catch (Minify_Source_FactoryException $e) { $this->logger->error($e->getMessage()); return new Minify_ServeConfiguration($options); } } return new Minify_ServeConfiguration($options, $sources); }
[ "public", "function", "createConfiguration", "(", "array", "$", "options", ")", "{", "// strip controller options", "$", "files", "=", "$", "options", "[", "'files'", "]", ";", "// if $files is a single object, casting will break it", "if", "(", "is_object", "(", "$", "files", ")", ")", "{", "$", "files", "=", "array", "(", "$", "files", ")", ";", "}", "elseif", "(", "!", "is_array", "(", "$", "files", ")", ")", "{", "$", "files", "=", "(", "array", ")", "$", "files", ";", "}", "unset", "(", "$", "options", "[", "'files'", "]", ")", ";", "$", "sources", "=", "array", "(", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "try", "{", "$", "sources", "[", "]", "=", "$", "this", "->", "sourceFactory", "->", "makeSource", "(", "$", "file", ")", ";", "}", "catch", "(", "Minify_Source_FactoryException", "$", "e", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "return", "new", "Minify_ServeConfiguration", "(", "$", "options", ")", ";", "}", "}", "return", "new", "Minify_ServeConfiguration", "(", "$", "options", ",", "$", "sources", ")", ";", "}" ]
Set up file sources @param array $options controller and Minify options @return Minify_ServeConfiguration Controller options: 'files': (required) array of complete file paths, or a single path
[ "Set", "up", "file", "sources" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Controller/Files.php#L44-L69
train
mrclay/minify
lib/Minify/Lines.php
Minify_Lines.minify
public static function minify($content, $options = array()) { $id = (isset($options['id']) && $options['id']) ? $options['id'] : ''; $content = str_replace("\r\n", "\n", $content); $lines = explode("\n", $content); $numLines = count($lines); // determine left padding $padTo = strlen((string) $numLines); // e.g. 103 lines = 3 digits $inComment = false; $i = 0; $newLines = array(); while (null !== ($line = array_shift($lines))) { if (('' !== $id) && (0 === $i % 50)) { if ($inComment) { array_push($newLines, '', "/* {$id} *|", ''); } else { array_push($newLines, '', "/* {$id} */", ''); } } ++$i; $newLines[] = self::_addNote($line, $i, $inComment, $padTo); $inComment = self::_eolInComment($line, $inComment); } $content = implode("\n", $newLines) . "\n"; // check for desired URI rewriting if (isset($options['currentDir'])) { Minify_CSS_UriRewriter::$debugText = ''; $docRoot = isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT']; $symlinks = isset($options['symlinks']) ? $options['symlinks'] : array(); $content = Minify_CSS_UriRewriter::rewrite($content, $options['currentDir'], $docRoot, $symlinks); $content = "/* Minify_CSS_UriRewriter::\$debugText\n\n" . Minify_CSS_UriRewriter::$debugText . "*/\n" . $content; } return $content; }
php
public static function minify($content, $options = array()) { $id = (isset($options['id']) && $options['id']) ? $options['id'] : ''; $content = str_replace("\r\n", "\n", $content); $lines = explode("\n", $content); $numLines = count($lines); // determine left padding $padTo = strlen((string) $numLines); // e.g. 103 lines = 3 digits $inComment = false; $i = 0; $newLines = array(); while (null !== ($line = array_shift($lines))) { if (('' !== $id) && (0 === $i % 50)) { if ($inComment) { array_push($newLines, '', "/* {$id} *|", ''); } else { array_push($newLines, '', "/* {$id} */", ''); } } ++$i; $newLines[] = self::_addNote($line, $i, $inComment, $padTo); $inComment = self::_eolInComment($line, $inComment); } $content = implode("\n", $newLines) . "\n"; // check for desired URI rewriting if (isset($options['currentDir'])) { Minify_CSS_UriRewriter::$debugText = ''; $docRoot = isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT']; $symlinks = isset($options['symlinks']) ? $options['symlinks'] : array(); $content = Minify_CSS_UriRewriter::rewrite($content, $options['currentDir'], $docRoot, $symlinks); $content = "/* Minify_CSS_UriRewriter::\$debugText\n\n" . Minify_CSS_UriRewriter::$debugText . "*/\n" . $content; } return $content; }
[ "public", "static", "function", "minify", "(", "$", "content", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "id", "=", "(", "isset", "(", "$", "options", "[", "'id'", "]", ")", "&&", "$", "options", "[", "'id'", "]", ")", "?", "$", "options", "[", "'id'", "]", ":", "''", ";", "$", "content", "=", "str_replace", "(", "\"\\r\\n\"", ",", "\"\\n\"", ",", "$", "content", ")", ";", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "content", ")", ";", "$", "numLines", "=", "count", "(", "$", "lines", ")", ";", "// determine left padding", "$", "padTo", "=", "strlen", "(", "(", "string", ")", "$", "numLines", ")", ";", "// e.g. 103 lines = 3 digits", "$", "inComment", "=", "false", ";", "$", "i", "=", "0", ";", "$", "newLines", "=", "array", "(", ")", ";", "while", "(", "null", "!==", "(", "$", "line", "=", "array_shift", "(", "$", "lines", ")", ")", ")", "{", "if", "(", "(", "''", "!==", "$", "id", ")", "&&", "(", "0", "===", "$", "i", "%", "50", ")", ")", "{", "if", "(", "$", "inComment", ")", "{", "array_push", "(", "$", "newLines", ",", "''", ",", "\"/* {$id} *|\"", ",", "''", ")", ";", "}", "else", "{", "array_push", "(", "$", "newLines", ",", "''", ",", "\"/* {$id} */\"", ",", "''", ")", ";", "}", "}", "++", "$", "i", ";", "$", "newLines", "[", "]", "=", "self", "::", "_addNote", "(", "$", "line", ",", "$", "i", ",", "$", "inComment", ",", "$", "padTo", ")", ";", "$", "inComment", "=", "self", "::", "_eolInComment", "(", "$", "line", ",", "$", "inComment", ")", ";", "}", "$", "content", "=", "implode", "(", "\"\\n\"", ",", "$", "newLines", ")", ".", "\"\\n\"", ";", "// check for desired URI rewriting", "if", "(", "isset", "(", "$", "options", "[", "'currentDir'", "]", ")", ")", "{", "Minify_CSS_UriRewriter", "::", "$", "debugText", "=", "''", ";", "$", "docRoot", "=", "isset", "(", "$", "options", "[", "'docRoot'", "]", ")", "?", "$", "options", "[", "'docRoot'", "]", ":", "$", "_SERVER", "[", "'DOCUMENT_ROOT'", "]", ";", "$", "symlinks", "=", "isset", "(", "$", "options", "[", "'symlinks'", "]", ")", "?", "$", "options", "[", "'symlinks'", "]", ":", "array", "(", ")", ";", "$", "content", "=", "Minify_CSS_UriRewriter", "::", "rewrite", "(", "$", "content", ",", "$", "options", "[", "'currentDir'", "]", ",", "$", "docRoot", ",", "$", "symlinks", ")", ";", "$", "content", "=", "\"/* Minify_CSS_UriRewriter::\\$debugText\\n\\n\"", ".", "Minify_CSS_UriRewriter", "::", "$", "debugText", ".", "\"*/\\n\"", ".", "$", "content", ";", "}", "return", "$", "content", ";", "}" ]
Add line numbers in C-style comments This uses a very basic parser easily fooled by comment tokens inside strings or regexes, but, otherwise, generally clean code will not be mangled. URI rewriting can also be performed. @param string $content @param array $options available options: 'id': (optional) string to identify file. E.g. file name/path 'currentDir': (default null) if given, this is assumed to be the directory of the current CSS file. Using this, minify will rewrite all relative URIs in import/url declarations to correctly point to the desired files, and prepend a comment with debugging information about this process. @return string
[ "Add", "line", "numbers", "in", "C", "-", "style", "comments" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Lines.php#L38-L81
train
mrclay/minify
lib/Minify/Lines.php
Minify_Lines._eolInComment
private static function _eolInComment($line, $inComment) { while (strlen($line)) { if ($inComment) { // only "*/" can end the comment $index = self::_find($line, '*/'); if ($index === false) { return true; } // stop comment and keep walking line $inComment = false; @$line = (string)substr($line, $index + 2); continue; } // look for "//" and "/*" $single = self::_find($line, '//'); $multi = self::_find($line, '/*'); if ($multi === false) { return false; } if ($single === false || $multi < $single) { // start comment and keep walking line $inComment = true; @$line = (string)substr($line, $multi + 2); continue; } // a single-line comment preceeded it return false; } return $inComment; }
php
private static function _eolInComment($line, $inComment) { while (strlen($line)) { if ($inComment) { // only "*/" can end the comment $index = self::_find($line, '*/'); if ($index === false) { return true; } // stop comment and keep walking line $inComment = false; @$line = (string)substr($line, $index + 2); continue; } // look for "//" and "/*" $single = self::_find($line, '//'); $multi = self::_find($line, '/*'); if ($multi === false) { return false; } if ($single === false || $multi < $single) { // start comment and keep walking line $inComment = true; @$line = (string)substr($line, $multi + 2); continue; } // a single-line comment preceeded it return false; } return $inComment; }
[ "private", "static", "function", "_eolInComment", "(", "$", "line", ",", "$", "inComment", ")", "{", "while", "(", "strlen", "(", "$", "line", ")", ")", "{", "if", "(", "$", "inComment", ")", "{", "// only \"*/\" can end the comment", "$", "index", "=", "self", "::", "_find", "(", "$", "line", ",", "'*/'", ")", ";", "if", "(", "$", "index", "===", "false", ")", "{", "return", "true", ";", "}", "// stop comment and keep walking line", "$", "inComment", "=", "false", ";", "@", "$", "line", "=", "(", "string", ")", "substr", "(", "$", "line", ",", "$", "index", "+", "2", ")", ";", "continue", ";", "}", "// look for \"//\" and \"/*\"", "$", "single", "=", "self", "::", "_find", "(", "$", "line", ",", "'//'", ")", ";", "$", "multi", "=", "self", "::", "_find", "(", "$", "line", ",", "'/*'", ")", ";", "if", "(", "$", "multi", "===", "false", ")", "{", "return", "false", ";", "}", "if", "(", "$", "single", "===", "false", "||", "$", "multi", "<", "$", "single", ")", "{", "// start comment and keep walking line", "$", "inComment", "=", "true", ";", "@", "$", "line", "=", "(", "string", ")", "substr", "(", "$", "line", ",", "$", "multi", "+", "2", ")", ";", "continue", ";", "}", "// a single-line comment preceeded it", "return", "false", ";", "}", "return", "$", "inComment", ";", "}" ]
Is the parser within a C-style comment at the end of this line? @param string $line current line of code @param bool $inComment was the parser in a C-style comment at the beginning of the previous line? @return bool
[ "Is", "the", "parser", "within", "a", "C", "-", "style", "comment", "at", "the", "end", "of", "this", "line?" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Lines.php#L93-L128
train
mrclay/minify
lib/Minify/Lines.php
Minify_Lines._find
private static function _find($str, $token) { switch ($token) { case '//': $fakes = array( '://' => 1, '"//' => 1, '\'//' => 1, '".//' => 2, '\'.//' => 2, ); break; case '/*': $fakes = array( '"/*' => 1, '\'/*' => 1, '"//*' => 2, '\'//*' => 2, '".//*' => 3, '\'.//*' => 3, '*/*' => 1, '\\/*' => 1, ); break; default: $fakes = array(); } $index = strpos($str, $token); $offset = 0; while ($index !== false) { foreach ($fakes as $fake => $skip) { $check = substr($str, $index - $skip, strlen($fake)); if ($check === $fake) { // move offset and scan again $offset += $index + strlen($token); $index = strpos($str, $token, $offset); break; } } // legitimate find return $index; } return $index; }
php
private static function _find($str, $token) { switch ($token) { case '//': $fakes = array( '://' => 1, '"//' => 1, '\'//' => 1, '".//' => 2, '\'.//' => 2, ); break; case '/*': $fakes = array( '"/*' => 1, '\'/*' => 1, '"//*' => 2, '\'//*' => 2, '".//*' => 3, '\'.//*' => 3, '*/*' => 1, '\\/*' => 1, ); break; default: $fakes = array(); } $index = strpos($str, $token); $offset = 0; while ($index !== false) { foreach ($fakes as $fake => $skip) { $check = substr($str, $index - $skip, strlen($fake)); if ($check === $fake) { // move offset and scan again $offset += $index + strlen($token); $index = strpos($str, $token, $offset); break; } } // legitimate find return $index; } return $index; }
[ "private", "static", "function", "_find", "(", "$", "str", ",", "$", "token", ")", "{", "switch", "(", "$", "token", ")", "{", "case", "'//'", ":", "$", "fakes", "=", "array", "(", "'://'", "=>", "1", ",", "'\"//'", "=>", "1", ",", "'\\'//'", "=>", "1", ",", "'\".//'", "=>", "2", ",", "'\\'.//'", "=>", "2", ",", ")", ";", "break", ";", "case", "'/*'", ":", "$", "fakes", "=", "array", "(", "'\"/*'", "=>", "1", ",", "'\\'/*'", "=>", "1", ",", "'\"//*'", "=>", "2", ",", "'\\'//*'", "=>", "2", ",", "'\".//*'", "=>", "3", ",", "'\\'.//*'", "=>", "3", ",", "'*/*'", "=>", "1", ",", "'\\\\/*'", "=>", "1", ",", ")", ";", "break", ";", "default", ":", "$", "fakes", "=", "array", "(", ")", ";", "}", "$", "index", "=", "strpos", "(", "$", "str", ",", "$", "token", ")", ";", "$", "offset", "=", "0", ";", "while", "(", "$", "index", "!==", "false", ")", "{", "foreach", "(", "$", "fakes", "as", "$", "fake", "=>", "$", "skip", ")", "{", "$", "check", "=", "substr", "(", "$", "str", ",", "$", "index", "-", "$", "skip", ",", "strlen", "(", "$", "fake", ")", ")", ";", "if", "(", "$", "check", "===", "$", "fake", ")", "{", "// move offset and scan again", "$", "offset", "+=", "$", "index", "+", "strlen", "(", "$", "token", ")", ";", "$", "index", "=", "strpos", "(", "$", "str", ",", "$", "token", ",", "$", "offset", ")", ";", "break", ";", "}", "}", "// legitimate find", "return", "$", "index", ";", "}", "return", "$", "index", ";", "}" ]
Find a token trying to avoid false positives @param string $str String containing the token @param string $token Token being checked @return bool
[ "Find", "a", "token", "trying", "to", "avoid", "false", "positives" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/Lines.php#L162-L208
train
mrclay/minify
lib/Minify/CSS/Compressor.php
Minify_CSS_Compressor._fontFamilyCB
protected function _fontFamilyCB($m) { // Issue 210: must not eliminate WS between words in unquoted families $flags = PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY; $pieces = preg_split('/(\'[^\']+\'|"[^"]+")/', $m[1], null, $flags); $out = 'font-family:'; while (null !== ($piece = array_shift($pieces))) { if ($piece[0] !== '"' && $piece[0] !== "'") { $piece = preg_replace('/\\s+/', ' ', $piece); $piece = preg_replace('/\\s?,\\s?/', ',', $piece); } $out .= $piece; } return $out . $m[2]; }
php
protected function _fontFamilyCB($m) { // Issue 210: must not eliminate WS between words in unquoted families $flags = PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY; $pieces = preg_split('/(\'[^\']+\'|"[^"]+")/', $m[1], null, $flags); $out = 'font-family:'; while (null !== ($piece = array_shift($pieces))) { if ($piece[0] !== '"' && $piece[0] !== "'") { $piece = preg_replace('/\\s+/', ' ', $piece); $piece = preg_replace('/\\s?,\\s?/', ',', $piece); } $out .= $piece; } return $out . $m[2]; }
[ "protected", "function", "_fontFamilyCB", "(", "$", "m", ")", "{", "// Issue 210: must not eliminate WS between words in unquoted families", "$", "flags", "=", "PREG_SPLIT_DELIM_CAPTURE", "|", "PREG_SPLIT_NO_EMPTY", ";", "$", "pieces", "=", "preg_split", "(", "'/(\\'[^\\']+\\'|\"[^\"]+\")/'", ",", "$", "m", "[", "1", "]", ",", "null", ",", "$", "flags", ")", ";", "$", "out", "=", "'font-family:'", ";", "while", "(", "null", "!==", "(", "$", "piece", "=", "array_shift", "(", "$", "pieces", ")", ")", ")", "{", "if", "(", "$", "piece", "[", "0", "]", "!==", "'\"'", "&&", "$", "piece", "[", "0", "]", "!==", "\"'\"", ")", "{", "$", "piece", "=", "preg_replace", "(", "'/\\\\s+/'", ",", "' '", ",", "$", "piece", ")", ";", "$", "piece", "=", "preg_replace", "(", "'/\\\\s?,\\\\s?/'", ",", "','", ",", "$", "piece", ")", ";", "}", "$", "out", ".=", "$", "piece", ";", "}", "return", "$", "out", ".", "$", "m", "[", "2", "]", ";", "}" ]
Process a font-family listing and return a replacement @param array $m regex matches @return string
[ "Process", "a", "font", "-", "family", "listing", "and", "return", "a", "replacement" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/CSS/Compressor.php#L258-L274
train
mrclay/minify
lib/HTTP/Encoder.php
HTTP_Encoder.getAcceptedEncoding
public static function getAcceptedEncoding($allowCompress = true, $allowDeflate = true) { // @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html if (! isset($_SERVER['HTTP_ACCEPT_ENCODING']) || self::isBuggyIe()) { return array('', ''); } $ae = $_SERVER['HTTP_ACCEPT_ENCODING']; // gzip checks (quick) if (0 === strpos($ae, 'gzip,') // most browsers || 0 === strpos($ae, 'deflate, gzip,') // opera ) { return array('gzip', 'gzip'); } // gzip checks (slow) if (preg_match( '@(?:^|,)\\s*((?:x-)?gzip)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@' ,$ae ,$m)) { return array('gzip', $m[1]); } if ($allowDeflate) { // deflate checks $aeRev = strrev($ae); if (0 === strpos($aeRev, 'etalfed ,') // ie, webkit || 0 === strpos($aeRev, 'etalfed,') // gecko || 0 === strpos($ae, 'deflate,') // opera // slow parsing || preg_match( '@(?:^|,)\\s*deflate\\s*(?:$|,|;\\s*q=(?:0\\.|1))@', $ae)) { return array('deflate', 'deflate'); } } if ($allowCompress && preg_match( '@(?:^|,)\\s*((?:x-)?compress)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@' ,$ae ,$m)) { return array('compress', $m[1]); } return array('', ''); }
php
public static function getAcceptedEncoding($allowCompress = true, $allowDeflate = true) { // @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html if (! isset($_SERVER['HTTP_ACCEPT_ENCODING']) || self::isBuggyIe()) { return array('', ''); } $ae = $_SERVER['HTTP_ACCEPT_ENCODING']; // gzip checks (quick) if (0 === strpos($ae, 'gzip,') // most browsers || 0 === strpos($ae, 'deflate, gzip,') // opera ) { return array('gzip', 'gzip'); } // gzip checks (slow) if (preg_match( '@(?:^|,)\\s*((?:x-)?gzip)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@' ,$ae ,$m)) { return array('gzip', $m[1]); } if ($allowDeflate) { // deflate checks $aeRev = strrev($ae); if (0 === strpos($aeRev, 'etalfed ,') // ie, webkit || 0 === strpos($aeRev, 'etalfed,') // gecko || 0 === strpos($ae, 'deflate,') // opera // slow parsing || preg_match( '@(?:^|,)\\s*deflate\\s*(?:$|,|;\\s*q=(?:0\\.|1))@', $ae)) { return array('deflate', 'deflate'); } } if ($allowCompress && preg_match( '@(?:^|,)\\s*((?:x-)?compress)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@' ,$ae ,$m)) { return array('compress', $m[1]); } return array('', ''); }
[ "public", "static", "function", "getAcceptedEncoding", "(", "$", "allowCompress", "=", "true", ",", "$", "allowDeflate", "=", "true", ")", "{", "// @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html", "if", "(", "!", "isset", "(", "$", "_SERVER", "[", "'HTTP_ACCEPT_ENCODING'", "]", ")", "||", "self", "::", "isBuggyIe", "(", ")", ")", "{", "return", "array", "(", "''", ",", "''", ")", ";", "}", "$", "ae", "=", "$", "_SERVER", "[", "'HTTP_ACCEPT_ENCODING'", "]", ";", "// gzip checks (quick)", "if", "(", "0", "===", "strpos", "(", "$", "ae", ",", "'gzip,'", ")", "// most browsers", "||", "0", "===", "strpos", "(", "$", "ae", ",", "'deflate, gzip,'", ")", "// opera", ")", "{", "return", "array", "(", "'gzip'", ",", "'gzip'", ")", ";", "}", "// gzip checks (slow)", "if", "(", "preg_match", "(", "'@(?:^|,)\\\\s*((?:x-)?gzip)\\\\s*(?:$|,|;\\\\s*q=(?:0\\\\.|1))@'", ",", "$", "ae", ",", "$", "m", ")", ")", "{", "return", "array", "(", "'gzip'", ",", "$", "m", "[", "1", "]", ")", ";", "}", "if", "(", "$", "allowDeflate", ")", "{", "// deflate checks", "$", "aeRev", "=", "strrev", "(", "$", "ae", ")", ";", "if", "(", "0", "===", "strpos", "(", "$", "aeRev", ",", "'etalfed ,'", ")", "// ie, webkit", "||", "0", "===", "strpos", "(", "$", "aeRev", ",", "'etalfed,'", ")", "// gecko", "||", "0", "===", "strpos", "(", "$", "ae", ",", "'deflate,'", ")", "// opera", "// slow parsing", "||", "preg_match", "(", "'@(?:^|,)\\\\s*deflate\\\\s*(?:$|,|;\\\\s*q=(?:0\\\\.|1))@'", ",", "$", "ae", ")", ")", "{", "return", "array", "(", "'deflate'", ",", "'deflate'", ")", ";", "}", "}", "if", "(", "$", "allowCompress", "&&", "preg_match", "(", "'@(?:^|,)\\\\s*((?:x-)?compress)\\\\s*(?:$|,|;\\\\s*q=(?:0\\\\.|1))@'", ",", "$", "ae", ",", "$", "m", ")", ")", "{", "return", "array", "(", "'compress'", ",", "$", "m", "[", "1", "]", ")", ";", "}", "return", "array", "(", "''", ",", "''", ")", ";", "}" ]
Determine the client's best encoding method from the HTTP Accept-Encoding header. If no Accept-Encoding header is set, or the browser is IE before v6 SP2, this will return ('', ''), the "identity" encoding. A syntax-aware scan is done of the Accept-Encoding, so the method must be non 0. The methods are favored in order of gzip, deflate, then compress. Deflate is always smallest and generally faster, but is rarely sent by servers, so client support could be buggier. @param bool $allowCompress allow the older compress encoding @param bool $allowDeflate allow the more recent deflate encoding @return array two values, 1st is the actual encoding method, 2nd is the alias of that method to use in the Content-Encoding header (some browsers call gzip "x-gzip" etc.)
[ "Determine", "the", "client", "s", "best", "encoding", "method", "from", "the", "HTTP", "Accept", "-", "Encoding", "header", "." ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/HTTP/Encoder.php#L190-L232
train
mrclay/minify
lib/HTTP/Encoder.php
HTTP_Encoder.output
public static function output($content, $compressionLevel = null) { if (null === $compressionLevel) { $compressionLevel = self::$compressionLevel; } $he = new HTTP_Encoder(array('content' => $content)); $ret = $he->encode($compressionLevel); $he->sendAll(); return $ret; }
php
public static function output($content, $compressionLevel = null) { if (null === $compressionLevel) { $compressionLevel = self::$compressionLevel; } $he = new HTTP_Encoder(array('content' => $content)); $ret = $he->encode($compressionLevel); $he->sendAll(); return $ret; }
[ "public", "static", "function", "output", "(", "$", "content", ",", "$", "compressionLevel", "=", "null", ")", "{", "if", "(", "null", "===", "$", "compressionLevel", ")", "{", "$", "compressionLevel", "=", "self", "::", "$", "compressionLevel", ";", "}", "$", "he", "=", "new", "HTTP_Encoder", "(", "array", "(", "'content'", "=>", "$", "content", ")", ")", ";", "$", "ret", "=", "$", "he", "->", "encode", "(", "$", "compressionLevel", ")", ";", "$", "he", "->", "sendAll", "(", ")", ";", "return", "$", "ret", ";", "}" ]
Encode and send appropriate headers and content This is a convenience method for common use of the class @param string $content @param int $compressionLevel given to zlib functions. If not given, the class default will be used. @return bool success true if the content was actually compressed
[ "Encode", "and", "send", "appropriate", "headers", "and", "content" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/HTTP/Encoder.php#L295-L305
train