This commit is contained in:
Doar Mihai
2026-04-04 18:19:34 +03:00
parent 5fb17f717d
commit 7c09846bd6
22 changed files with 1229 additions and 94 deletions
@@ -70,9 +70,32 @@ class RemotiveTransformer implements JobTransformer
return null;
}
// Try to extract numbers from salary string
if (preg_match_all('/[\d,]+/', $salary, $matches)) {
$numbers = array_map(fn($n) => (float) str_replace(',', '', $n), $matches[0]);
// Normalize the salary string
$salary = strtolower($salary);
// Check if it's hourly rate - if so, convert to annual (assuming 40hr/week * 52 weeks = 2080 hours/year)
$isHourly = str_contains($salary, '/hour') || str_contains($salary, 'per hour') || str_contains($salary, '/hr');
// Try to extract numbers with optional k/K suffix
// Pattern: number followed by optional comma-separated digits, then optional 'k'
if (preg_match_all('/\$?\s*([\d,]+)\s*([kK])?/', $salary, $matches, PREG_SET_ORDER)) {
$numbers = [];
foreach ($matches as $match) {
$number = (float) str_replace(',', '', $match[1]);
// If there's a 'k' suffix, multiply by 1000
if (!empty($match[2]) && strtolower($match[2]) === 'k') {
$number *= 1000;
}
// If it's hourly, convert to annual
if ($isHourly) {
$number *= 2080; // 40 hours/week * 52 weeks
}
$numbers[] = $number;
}
if (count($numbers) >= 2) {
return $type === 'min' ? min($numbers) : max($numbers);