/** * 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); }
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; }
public function message() { return String::substitute($this->message, (array) $this); }
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)); }
public function testGenerateHumanReadablePassword() { $this->assertRegExp('@^[a-z]{20}$@i', String::generateHumanReadablePassword(20)); }
public function validate($value) { return parent::validate(String::length((string) $value) == $this->length); }
public function validate($value) { return String::length((string) $value) >= $this->limit; }