src/Phone_number.php
public function detect_carrier($phone_number = '', $get_field_data = NULL)
    {
        $inputParams = array(
            'phone_number'   => $phone_number,
            'get_field_data' => $get_field_data
        );
        $this->debug->info(__FUNCTION__, 'Input Params: ', $inputParams);
        if (empty($phone_number)) {
            $this->debug->warning(__FUNCTION__, 'Phone Number input is Empty!');

            return NULL;
        }
        try {
            $carrierMapper     = PhoneNumberToCarrierMapper::getInstance();
            $phoneNumberObject = PhoneNumberUtil::getInstance()->parse(trim($phone_number), self::DEFAULT_REGION);
            $carrier           = $carrierMapper->getNameForNumber($phoneNumberObject, self::DEFAULT_LANGUAGE);
            $this->debug->debug(__FUNCTION__, 'Carrier Detect from ' . $phone_number . ' is ', $carrier);
            if ($get_field_data !== NULL) {
                $phone_telco = new Phone_telco();
                $phone_telco->setDebugStatus($this->debugStatus);
                $phone_telco->setLoggerPath($this->loggerPath);
                $phone_telco->__construct();
                $result = $phone_telco->carrier_data($carrier, $get_field_data);
                $this->debug->info(__FUNCTION__, 'Final Result: ', $result);

                return (string) $result;
            }
            if ($this->normal_name === TRUE) {
                $phone_telco = new Phone_telco();
                $phone_telco->setDebugStatus($this->debugStatus);
                $phone_telco->setLoggerPath($this->loggerPath);
                $phone_telco->__construct();
                $result = $phone_telco->carrier_data($carrier, 'name');
                if ($result !== NULL) {
                    return $result;
                }
                $this->debug->info(__FUNCTION__, 'Final Result: ', $result);
            }
            $this->debug->info(__FUNCTION__, 'Final Result: ', $carrier);

            return (string) $carrier;
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return NULL;
        }
    }
public function detect_carrier($phone_number = '', $get_field_data = NULL)
    {
        $inputParams = array(
            'phone_number'   => $phone_number,
            'get_field_data' => $get_field_data
        );
        $this->debug->info(__FUNCTION__, 'Input Params: ', $inputParams);
        if (empty($phone_number)) {
            $this->debug->warning(__FUNCTION__, 'Phone Number input is Empty!');

            return NULL;
        }
        try {
            $carrierMapper     = PhoneNumberToCarrierMapper::getInstance();
            $phoneNumberObject = PhoneNumberUtil::getInstance()->parse(trim($phone_number), self::DEFAULT_REGION);
            $carrier           = $carrierMapper->getNameForNumber($phoneNumberObject, self::DEFAULT_LANGUAGE);
            $this->debug->debug(__FUNCTION__, 'Carrier Detect from ' . $phone_number . ' is ', $carrier);
            if ($get_field_data !== NULL) {
                $phone_telco = new Phone_telco();
                $phone_telco->setDebugStatus($this->debugStatus);
                $phone_telco->setLoggerPath($this->loggerPath);
                $phone_telco->__construct();
                $result = $phone_telco->carrier_data($carrier, $get_field_data);
                $this->debug->info(__FUNCTION__, 'Final Result: ', $result);

                return (string) $result;
            }
            if ($this->normal_name === TRUE) {
                $phone_telco = new Phone_telco();
                $phone_telco->setDebugStatus($this->debugStatus);
                $phone_telco->setLoggerPath($this->loggerPath);
                $phone_telco->__construct();
                $result = $phone_telco->carrier_data($carrier, 'name');
                if ($result !== NULL) {
                    return $result;
                }
                $this->debug->info(__FUNCTION__, 'Final Result: ', $result);
            }
            $this->debug->info(__FUNCTION__, 'Final Result: ', $carrier);

            return (string) $carrier;
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return NULL;
        }
    }
Function detect_carrier
Detect Carrier from Phone Number
Nhận diện nhà mạng từ số điện thoại nhập vào

@author: 713uk13m <dev@nguyenanhung.com>
@time  : 10/9/18 14:37

@param string $phone_number   This is Phone Number to be Detect
@param null   $get_field_data Get File Data, keyword: name, short_name, id

@return mixed|null|string String if Success, Null if Errro