Redaxscript\Filter\Email::sanitize PHP Method

sanitize() public method

sanitize the email
Since: 2.2.0
public sanitize ( string $email = null ) : string
$email string target email address
return string
    public function sanitize($email = null)
    {
        return filter_var(strtolower($email), FILTER_SANITIZE_EMAIL);
    }

Usage Example

Example #1
0
 /**
  * process the class
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function process()
 {
     $emailFilter = new Filter\Email();
     /* process post */
     $postArray = ['email' => $emailFilter->sanitize($this->_request->getPost('email')), 'task' => $this->_request->getPost('task'), 'solution' => $this->_request->getPost('solution')];
     /* handle error */
     $messageArray = $this->_validate($postArray);
     if ($messageArray) {
         return $this->_error(['message' => $messageArray]);
     }
     /* handle success */
     $messageArray = [];
     $users = Db::forTablePrefix('users')->where(['email' => $postArray['email'], 'status' => 1])->findMany();
     /* process users */
     foreach ($users as $user) {
         $mailArray = ['id' => $user->id, 'name' => $user->name, 'user' => $user->user, 'password' => $user->password, 'email' => $user->email];
         if ($this->_mail($mailArray)) {
             $messageArray[] = $user->name . $this->_language->get('colon') . ' ' . $this->_language->get('recovery_sent');
         }
     }
     if ($messageArray) {
         return $this->_success(['message' => $messageArray]);
     }
     return $this->_error(['message' => $this->_language->get('something_wrong')]);
 }
All Usage Examples Of Redaxscript\Filter\Email::sanitize