<?php

namespace App\Helpers;


class Phone
{
    public static function getOperator($phoneNo)
    {
        $prefix = substr($phoneNo, 3, 2);

        if ($prefix >= '74' && $prefix <= '79') {
            $operator = "Telenor";
        } elseif ($prefix >= '90' && $prefix <= '99') {
            if ($prefix == '93') {
                $operator = "MEC";
            } else {
                $operator = "Ooredoo";
            }
        } elseif ($prefix >= '30' && $prefix <= '39') {
            $operator = "MEC";
        } elseif ($prefix >= '65' && $prefix <= '69') {
            $operator = "Mytel";
        } else {
            $operator = "MPT";
        }

        return $operator;
    }


    public static function getAmount($amount)
    {
        $gettype = gettype($amount);
        if ($gettype == "string") {
            if (strpos(',', $amount) !== false) {
                $getAmount = str_replace(',', '', $amount);
            } else {
                $getAmount = $amount;
            }
        } else {
            $getAmount = $amount;
        }


        return $getAmount;
    }
}
