currency($amount) : null); /* if ($money < 0) */ /* return "($ " . number_format(-1*$money, 2) . ")"; */ /* else */ /* return "$ " . number_format($money, 2); */ } function date($date) { $date_fmt = 'm/d/Y'; return (isset($date) ? self::$time->format($date_fmt, $date) //? date_format(date_create($date), $date_fmt) : null); } function datetime($datetime) { if (!$datetime) return null; return self::$time->nice($datetime); } function phone($phone) { if (!isset($phone)) return null; $phone = preg_replace("/\D/", "", $phone); if(strlen($phone) == 7) return preg_replace("/(\d{3})(\d{4})/", "$1-$2", $phone); elseif(strlen($phone) == 10) return preg_replace("/(\d{3})(\d{3})(\d{4})/", "$1-$2-$3", $phone); else return $phone; } function comment($comment) { if (isset($comment) && is_array($comment)) { foreach (array_keys($comment) AS $k) { if (!$comment[$k]) unset($comment[$k]); } return implode('; ', $comment); } return $comment; } }