Clean-room copy of the reusable engines from comiida, with all instance data, secrets, dependencies, and build output excluded: - app/ Astro theme skeleton (no comiida blog posts; hero image -> placeholder) - api/ SeedProject PHP framework (no vendor/.env/config.php) - content-pipeline/ engine only (scripts/admin/prompts; empty runtime state) - astroagent.config.json + app/.astroagent/skills Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SYHWLHihq3v9nxNwoPCKSn
84 lines
No EOL
2.6 KiB
PHP
84 lines
No EOL
2.6 KiB
PHP
<?php
|
|
|
|
|
|
class Format {
|
|
|
|
public static function Date($d, $format = 'm-d-Y') {
|
|
return date($format , strtotime($d));
|
|
}
|
|
|
|
|
|
public static function Phone($phoneNumber) {
|
|
$phoneNumber = preg_replace('/[^0-9]/','',$phoneNumber);
|
|
|
|
if(strlen($phoneNumber) > 10) {
|
|
$countryCode = substr($phoneNumber, 0, strlen($phoneNumber)-10);
|
|
$areaCode = substr($phoneNumber, -10, 3);
|
|
$nextThree = substr($phoneNumber, -7, 3);
|
|
$lastFour = substr($phoneNumber, -4, 4);
|
|
|
|
$phoneNumber = '+'.$countryCode.' ('.$areaCode.') '.$nextThree.'-'.$lastFour;
|
|
}
|
|
else if(strlen($phoneNumber) == 10) {
|
|
$areaCode = substr($phoneNumber, 0, 3);
|
|
$nextThree = substr($phoneNumber, 3, 3);
|
|
$lastFour = substr($phoneNumber, 6, 4);
|
|
|
|
$phoneNumber = '('.$areaCode.') '.$nextThree.'-'.$lastFour;
|
|
}
|
|
else if(strlen($phoneNumber) == 7) {
|
|
$nextThree = substr($phoneNumber, 0, 3);
|
|
$lastFour = substr($phoneNumber, 3, 4);
|
|
|
|
$phoneNumber = $nextThree.'-'.$lastFour;
|
|
}
|
|
|
|
return $phoneNumber;
|
|
}
|
|
|
|
public static function formatCurrency($amount='', $thousands='') {
|
|
// Convert to float and divide by 100
|
|
$formattedAmount = number_format($amount / 100, 2, '.', $thousands);
|
|
|
|
return $formattedAmount;
|
|
}
|
|
|
|
|
|
/**
|
|
* Convert Equifax date strings to MM/DD/YYYY display format.
|
|
* Handles: YYYYMMDD, YYYY-MM-DD, MM/YYYY, MM/DD/YYYY passthrough.
|
|
* Returns null on empty/null input.
|
|
*/
|
|
public static function eqFormatDate($date) {
|
|
if (empty($date)) return null;
|
|
$date = trim((string)$date);
|
|
|
|
// YYYYMMDD (8 digits)
|
|
if (preg_match('/^\d{8}$/', $date)) {
|
|
$d = \DateTime::createFromFormat('Ymd', $date);
|
|
return $d ? $d->format('m/d/Y') : null;
|
|
}
|
|
|
|
// YYYY-MM-DD
|
|
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $date)) {
|
|
$d = \DateTime::createFromFormat('Y-m-d', $date);
|
|
return $d ? $d->format('m/d/Y') : null;
|
|
}
|
|
|
|
// MM/YYYY — partial date, use first of month
|
|
if (preg_match('/^\d{2}\/\d{4}$/', $date)) {
|
|
$d = \DateTime::createFromFormat('m/Y', $date);
|
|
return $d ? $d->format('m/01/Y') : null;
|
|
}
|
|
|
|
// MM/DD/YYYY — already correct format, passthrough
|
|
if (preg_match('/^\d{2}\/\d{2}\/\d{4}$/', $date)) {
|
|
return $date;
|
|
}
|
|
|
|
// Fallback: try strtotime
|
|
$ts = strtotime($date);
|
|
return $ts ? date('m/d/Y', $ts) : null;
|
|
}
|
|
|
|
} // End Class
|