idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
6,100
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
6,101
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
6,102
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
6,103
public function setName ( $ name ) { if ( ! is_string ( $ name ) ) { throw new TypeException ( '$name must be of type string.' ) ; } if ( false !== strpos ( $ name , ',' ) || false !== strpos ( $ name , ';' ) ) { $ name = stripslashes ( html_entity_decode ( $ name , ENT_QUOTES ) ) ; $ name = str_replace ( '"' , '\\"' , $ name ) ; $ name = '"' . $ name . '"' ; } $ this -> name = ( ! empty ( $ name ) ) ? $ name : null ; }
Add a name to a EmailAddress object
6,104
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
6,105
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
6,106
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
6,107
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
6,108
public function getCategory ( $ categories ) { $ this -> validateNumericArray ( 'categories' , $ categories ) ; $ stats = $ this -> getGlobal ( ) ; $ stats [ 'categories' ] = $ categories ; return $ stats ; }
Retrieve an array of categories
6,109
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
6,110
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
6,111
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
6,112
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
6,113
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
6,114
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
6,115
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
6,116
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
6,117
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
6,118
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
6,119
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
6,120
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
6,121
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
6,122
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
6,123
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
6,124
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
6,125
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
6,126
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
6,127
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 ] ) ) { $ 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
6,128
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
6,129
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
6,130
public function addTos ( $ toEmails , $ personalizationIndex = null , $ personalization = null ) { $ this -> addRecipientEmails ( "To" , $ toEmails , $ personalizationIndex , $ personalization ) ; }
Adds multiple email recipients to a Personalization object
6,131
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
6,132
public function addCcs ( $ ccEmails , $ personalizationIndex = null , $ personalization = null ) { $ this -> addRecipientEmails ( "Cc" , $ ccEmails , $ personalizationIndex , $ personalization ) ; }
Adds multiple email cc recipients to a Personalization object
6,133
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
6,134
public function addBccs ( $ bccEmails , $ personalizationIndex = null , $ personalization = null ) { $ this -> addRecipientEmails ( "Bcc" , $ bccEmails , $ personalizationIndex , $ personalization ) ; }
Adds multiple email bcc recipients to a Personalization object
6,135
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
6,136
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
6,137
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
6,138
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
6,139
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
6,140
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
6,141
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
6,142
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
6,143
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
6,144
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
6,145
public function setGlobalSubject ( $ subject ) { if ( ! ( $ subject instanceof Subject ) ) { $ subject = new Subject ( $ subject ) ; } $ this -> subject = $ subject ; }
Add a subject to a Mail object
6,146
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
6,147
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
6,148
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
6,149
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
6,150
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
6,151
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
6,152
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
6,153
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
6,154
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
6,155
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
6,156
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
6,157
public function addCategory ( $ category ) { if ( ! ( $ category instanceof Category ) ) { $ category = new Category ( $ category ) ; } $ this -> categories [ ] = $ category ; }
Add a category to a Mail object
6,158
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
6,159
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
6,160
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
6,161
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
6,162
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
6,163
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
6,164
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
6,165
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
6,166
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
6,167
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
6,168
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
6,169
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
6,170
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
6,171
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
6,172
public function jsonSerialize ( ) { $ 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
6,173
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
6,174
public static function rewriteRelative ( $ uri , $ realCurrentDir , $ realDocRoot , $ symlinks = array ( ) ) { $ path = strtr ( $ realCurrentDir , '/' , DIRECTORY_SEPARATOR ) ; $ path .= DIRECTORY_SEPARATOR . strtr ( $ uri , '/' , DIRECTORY_SEPARATOR ) ; self :: $ debugText .= "file-relative URI : {$uri}\n" . "path prepended : {$path}\n" ; foreach ( $ symlinks as $ link => $ target ) { if ( 0 === strpos ( $ path , $ target ) ) { $ path = $ link . substr ( $ path , strlen ( $ target ) ) ; self :: $ debugText .= "symlink unresolved : {$path}\n" ; break ; } } $ path = substr ( $ path , strlen ( $ realDocRoot ) ) ; self :: $ debugText .= "docroot stripped : {$path}\n" ; $ 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
6,175
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
6,176
public function uri ( $ uri , $ forceAmpersand = false ) { $ sep = ( $ forceAmpersand || strpos ( $ uri , '?' ) !== false ) ? self :: $ ampersand : '?' ; return "{$uri}{$sep}{$this->lastModified}" ; }
Get a time - stamped URI
6,177
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
6,178
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
6,179
public function createConfiguration ( array $ options ) { if ( isset ( $ options [ 'file' ] ) ) { $ sourceSpec = array ( 'filepath' => $ options [ 'file' ] ) ; $ f = $ options [ 'file' ] ; } else { $ sourceSpec = array ( 'content' => $ options [ 'content' ] , 'id' => $ options [ 'id' ] , ) ; $ f = $ options [ 'id' ] ; unset ( $ options [ 'content' ] , $ options [ 'id' ] ) ; } $ selectionId = strtr ( substr ( $ f , 1 + strlen ( dirname ( dirname ( $ f ) ) ) ) , '/\\' , ',,' ) ; if ( isset ( $ options [ 'minifyAll' ] ) ) { $ 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
6,180
private function getCache ( ) { if ( isset ( $ this -> parsed ) ) { return $ this -> parsed ; } $ 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
6,181
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 .
6,182
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
6,183
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 .
6,184
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 .
6,185
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
6,186
protected function _isCacheValid ( ) { if ( null === $ this -> _etag ) { 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
6,187
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'" ) ; } 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 .
6,188
public function isValid ( $ id , $ srcMtime ) { $ file = $ this -> path . '/' . $ id ; return ( is_file ( $ file ) && ( filemtime ( $ file ) >= $ srcMtime ) ) ; }
Does a valid cache entry exist?
6,189
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
6,190
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
6,191
protected function getServerCommandLine ( ) { $ this -> checkJar ( self :: $ ngJarFile ) ; $ this -> checkJar ( self :: $ jarFile ) ; $ classPath = array ( self :: $ ngJarFile , self :: $ jarFile , ) ; $ server = array ( self :: $ javaExecutable , '-server' , '-cp' , implode ( ':' , $ classPath ) , self :: NG_SERVER , ) ; return $ server ; }
Get command to launch NailGun server .
6,192
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
6,193
public function createConfiguration ( array $ options ) { $ files = $ options [ 'files' ] ; 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
6,194
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 ) ; $ padTo = strlen ( ( string ) $ numLines ) ; $ 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" ; 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
6,195
private static function _eolInComment ( $ line , $ inComment ) { while ( strlen ( $ line ) ) { if ( $ inComment ) { $ index = self :: _find ( $ line , '*/' ) ; if ( $ index === false ) { return true ; } $ inComment = false ; @ $ line = ( string ) substr ( $ line , $ index + 2 ) ; continue ; } $ single = self :: _find ( $ line , '//' ) ; $ multi = self :: _find ( $ line , '/*' ) ; if ( $ multi === false ) { return false ; } if ( $ single === false || $ multi < $ single ) { $ inComment = true ; @ $ line = ( string ) substr ( $ line , $ multi + 2 ) ; continue ; } return false ; } return $ inComment ; }
Is the parser within a C - style comment at the end of this line?
6,196
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 ) { $ offset += $ index + strlen ( $ token ) ; $ index = strpos ( $ str , $ token , $ offset ) ; break ; } } return $ index ; } return $ index ; }
Find a token trying to avoid false positives
6,197
protected function _fontFamilyCB ( $ m ) { $ 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
6,198
public static function getAcceptedEncoding ( $ allowCompress = true , $ allowDeflate = true ) { if ( ! isset ( $ _SERVER [ 'HTTP_ACCEPT_ENCODING' ] ) || self :: isBuggyIe ( ) ) { return array ( '' , '' ) ; } $ ae = $ _SERVER [ 'HTTP_ACCEPT_ENCODING' ] ; if ( 0 === strpos ( $ ae , 'gzip,' ) || 0 === strpos ( $ ae , 'deflate, gzip,' ) ) { return array ( 'gzip' , 'gzip' ) ; } if ( preg_match ( '@(?:^|,)\\s*((?:x-)?gzip)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@' , $ ae , $ m ) ) { return array ( 'gzip' , $ m [ 1 ] ) ; } if ( $ allowDeflate ) { $ aeRev = strrev ( $ ae ) ; if ( 0 === strpos ( $ aeRev , 'etalfed ,' ) || 0 === strpos ( $ aeRev , 'etalfed,' ) || 0 === strpos ( $ ae , 'deflate,' ) || 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 .
6,199
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