mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Merge pull request #64 from evseevnn/patch-1
Modifiers: Remove unnecessary check for the string and fix regexp
This commit is contained in:
commit
df08e491a7
@ -25,7 +25,7 @@ class Modifier
|
|||||||
*/
|
*/
|
||||||
public static function dateFormat($date, $format = "%b %e, %Y")
|
public static function dateFormat($date, $format = "%b %e, %Y")
|
||||||
{
|
{
|
||||||
if (is_string($date) && !is_numeric($date)) {
|
if (!is_numeric($date)) {
|
||||||
$date = strtotime($date);
|
$date = strtotime($date);
|
||||||
if (!$date) $date = time();
|
if (!$date) $date = time();
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ class Modifier
|
|||||||
*/
|
*/
|
||||||
public static function date($date, $format = "Y m d")
|
public static function date($date, $format = "Y m d")
|
||||||
{
|
{
|
||||||
if (is_string($date) && !is_numeric($date)) {
|
if (!is_numeric($date)) {
|
||||||
$date = strtotime($date);
|
$date = strtotime($date);
|
||||||
if (!$date) $date = time();
|
if (!$date) $date = time();
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ class Modifier
|
|||||||
if (preg_match('#^(.{' . $length . '}).*?(.{' . $length . '})?$#usS', $string, $match)) {
|
if (preg_match('#^(.{' . $length . '}).*?(.{' . $length . '})?$#usS', $string, $match)) {
|
||||||
if (count($match) == 3) {
|
if (count($match) == 3) {
|
||||||
if ($by_words) {
|
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 {
|
} else {
|
||||||
return $match[1] . $etc . $match[2];
|
return $match[1] . $etc . $match[2];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user