Reformat. Fix pipe. Add more tests

This commit is contained in:
bzick
2014-05-06 14:22:58 +04:00
parent 6f969ee124
commit cd490d2bf6
20 changed files with 1625 additions and 739 deletions

View File

@@ -27,7 +27,9 @@ class Modifier
{
if (!is_numeric($date)) {
$date = strtotime($date);
if (!$date) $date = time();
if (!$date) {
$date = time();
}
}
return strftime($format, $date);
}
@@ -41,7 +43,9 @@ class Modifier
{
if (!is_numeric($date)) {
$date = strtotime($date);
if (!$date) $date = time();
if (!$date) {
$date = time();
}
}
return date($format, $date);
}
@@ -103,7 +107,11 @@ class Modifier
if (preg_match('#^(.{' . $length . '}).*?(.{' . $length . '})?$#usS', $string, $match)) {
if (count($match) == 3) {
if ($by_words) {
return preg_replace('#\s.*$#usS', "", $match[1]) . $etc . preg_replace('#.*\s#usS', "", $match[2]);
return preg_replace('#\s.*$#usS', "", $match[1]) . $etc . preg_replace(
'#.*\s#usS',
"",
$match[2]
);
} else {
return $match[1] . $etc . $match[2];
}