Exemplo n.º 1
0
 /**
  * Constructor...
  *
  * @param String $name The name of this argument
  * @param \r8\iface\Filter $filter The filter to apply to this argument's data
  * @param \r8\iface\Validator $validator The validator to use for checking
  *      this argument's data
  */
 public function __construct($name, \r8\iface\Filter $filter = NULL, \r8\iface\Validator $validator = NULL)
 {
     $name = \r8\str\stripNoPrint($name);
     if (\r8\isEmpty($name)) {
         throw new \r8\Exception\Argument(0, "Name", "Must not be empty");
     }
     $this->name = $name;
     $this->filter = $filter ?: new \r8\Filter\Identity();
     $this->validator = $validator ?: new \r8\Validator\Pass();
 }
Exemplo n.º 2
0
 /**
  * Returns an e-mail address formatted as such: Name <*****@*****.**>
  *
  * @param String $email The e-mail address
  * @param String $name The name of the person associated with the address
  * @return String The well formatted address line
  */
 public static function formatAddress($email, $name = NULL)
 {
     $email = r8(new \r8\Filter\Email())->filter($email);
     if (!\r8\isVague($name)) {
         $name = trim(\r8\str\stripNoPrint($name));
     }
     if (\r8\isVague($name)) {
         return "<" . $email . ">";
     } else {
         return '"' . addslashes($name) . '" <' . $email . '>';
     }
 }
Exemplo n.º 3
0
 /**
  * Constructor...
  *
  * @param String $name The name of this command
  * @param String $description A description of this command
  */
 public function __construct($name, $description)
 {
     $name = \r8\str\stripNoPrint($name);
     if (\r8\isEmpty($name)) {
         throw new \r8\Exception\Argument(0, "Name", "Must not be empty");
     }
     $description = \r8\str\stripNoPrint($description);
     if (\r8\isEmpty($description)) {
         throw new \r8\Exception\Argument(0, "Description", "Must not be empty");
     }
     $this->name = $name;
     $this->description = $description;
     $this->forms[] = new \r8\CLI\Form();
 }
Exemplo n.º 4
0
 /**
  * Cleans up a string in preparation for
  *
  * @param Mixed $value The value to filter
  * @return String
  */
 public function filter($value)
 {
     return \r8\str\stripNoPrint($value);
 }
Exemplo n.º 5
0
 public function testStripNoPrint()
 {
     $this->assertSame("", \r8\str\stripNoPrint(""));
     $chars = implode("", array_map('chr', range(0, 255)));
     $this->assertSame(" !\"#\$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[" . "\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", \r8\str\stripNoPrint($chars));
 }
Exemplo n.º 6
0
 /**
  * Set the message ID of the email
  *
  * @param String $messageID The email message ID
  * @return \r8\Mail Returns a self reference
  */
 public function setMessageID($messageID)
 {
     // Strip out any new lines or tabs
     $messageID = str_replace(array("\r\n", "\r", "\n", "\t"), " ", $messageID);
     $messageID = trim(\r8\str\stripNoPrint($messageID));
     $this->messageID = \r8\isEmpty($messageID) ? NULL : $messageID;
     return $this;
 }