<?php

namespace App\Helpers\Normalizer;

class PriceNormalizer
{
    public static function normalizePrice($price)
    {
        try {
            $price = preg_replace('/[\p{C}\p{Z}]/u', '', $price);
            $price = str_replace(['$', '€', '£', '¥', ' ', ','], '', $price);
            $price = substr_replace($price, '.', -2, 0);
            $price = number_format($price, 2, '.', '');
        } catch (\Exception $e) {
            $price = null;
        }
        return $price;
    }
}
