Esempio n. 1
0
 /**
  * Return the first $count sentences from a $text
  * 
  * @param string $text
  * @param integer $count
  * @return string
  */
 public static function excerpt($text, $count = 1)
 {
     $sentenceCount = preg_match_all(self::$excerptRegexp, $text, $found, PREG_OFFSET_CAPTURE);
     if ($count > $sentenceCount) {
         return $text;
     }
     $excerpt = substr($text, 0, $found[0][$count - 1][1] + 2);
     return String::closeTags($excerpt);
 }
Esempio n. 2
0
 public function apply($value)
 {
     $result = basename((string) $value);
     $result = preg_replace('@[/?*:;{}\\\\]@', '', $result);
     if ($this->paranoid) {
         $result = preg_replace('@[^A-Z0-9_.-]@i', '', $result);
     }
     if (String::length($result) > $this->maxLength) {
         if (($dotPos = strpos($result, '.')) !== false) {
             $extension = substr($result, $dotPos + 1);
             $basename = substr($result, 0, $dotPos);
             $result = String::substr($basename, 0, $this->maxLength - String::length($extension) - 1) . '.' . $extension;
         } else {
             $result = String::substr($result, 0, $this->maxLength);
         }
     }
     return $result;
 }
Esempio n. 3
0
 public function message()
 {
     return String::substitute($this->message, (array) $this);
 }
Esempio n. 4
0
 public function format(Event $Event)
 {
     return \ephFrame\util\String::substitute($this->format, array('priority' => $Event->priority, 'timestamp' => $Event->created->getTimeStamp(), 'date' => $Event->created->format('Y-m-d'), 'time' => $Event->created->format('h:m:s'), 'message' => (string) $Event->message));
 }
Esempio n. 5
0
 public function testGenerateHumanReadablePassword()
 {
     $this->assertRegExp('@^[a-z]{20}$@i', String::generateHumanReadablePassword(20));
 }
Esempio n. 6
0
 public function validate($value)
 {
     return parent::validate(String::length((string) $value) == $this->length);
 }
Esempio n. 7
0
 public function validate($value)
 {
     return String::length((string) $value) >= $this->limit;
 }