<?php

namespace App\Traits;

use App\Facades\Settings;

trait FormatsPhoneNumber
{
    public function getFormattedPhoneNumber(string $number): string
    {
        return match (Settings::get('app-phone-number-format')) {
            '3-3-4' => substr($number, 0, 3) . ' ' . substr($number, 3, 3) . ' ' . substr($number, 6),
            '4-3-3' => substr($number, 0, 4) . ' ' . substr($number, 4, 3) . ' ' . substr($number, 7),
            '5-3-3' => substr($number, 0, 5) . ' ' . substr($number, 5, 3) . ' ' . substr($number, 8),
            '5-6' => substr($number, 0, 5) . ' ' . substr($number, 5),
            default => $number
        };
    }
}
