Format the phone number in a given format.

@param string $format
@return string
@throws \Propaganistas\LaravelPhone\Exceptions\NumberFormatException
343550
public function format($format)
    {
        $parsedFormat = static::parseFormat($format);

        if (is_null($parsedFormat)) {
            throw NumberFormatException::invalid($format);
        }

        return $this->lib->format(
            $this->getPhoneNumberInstance(),
            $parsedFormat
        );
    }
436339
public function format(): Format\Format
    {
        if (null === $this->format) {
            $this->format = Format\Format::fromJson($this);
        }

        return $this->format;
    }
925119
public function getLatitude(string $format = self::FORMAT_DECIMAL)
    {
        if (self::FORMAT_DMS === $format) {
            return $this->toDms($this->latitude, self::LATITUDE);
        }

        return $this->latitude;
    }
756018
public function format($format)
    {
        $pad    = false;
        $rChar  = 'hmsfHMS';
        $string = $this->format = $format;
        $string = static::encode($string, $rChar);

        // Perform rounding.
        $this->round = static::maxRound($format);

        // Decimal years, weeks, days, hours, minutes, and seconds
        static::fmtRep('Y', $string, $this->years);
        static::fmtRep('W', $string, $this->weeks);
        static::fmtRep('D', $string, $this->days);
        static::fmtRep('H', $string, $this->hours);
        static::fmtRep('M', $string, $this->min);
        static::fmtRep('S', $string, $this->sec);

        // Leading zeros h m s
        $string = str_replace('0h', sprintf('%02d', $this->h), $string);
        $string = str_replace('0m', sprintf('%02d', $this->m), $string);
        $string = str_replace('0s', sprintf('%02d', $this->s), $string);

        // No leading zeros, h m s
        $string = str_replace('h', $this->h, $string);
        $string = str_replace('m', $this->m, $string);
        $string = str_replace('s', $this->s, $string);

        // Fractional seconds.
        if (preg_match_all('/([0-9])f/', $string, $m)) {
            for ($i = 0; $i < count($m[0]); $i++) {
                $f = substr($this->f, 0, $m[1][$i]);

                if ($pad) {
                    $f      = str_pad($f, $m[1][$i], '0');
                    $string = str_replace($m[0][$i], $f, $string);
                } else {
                    if ($f == 0) {
                        $string = str_replace('.' . $m[0][$i], '', $string);
                        $string = str_replace($m[0][$i], '', $string);
                    } else {
                        $string = str_replace($m[0][$i], $f, $string);
                    }
                }
            }
        }

        return static::decode($string, $rChar);
    }
396598
public function format($format = self::FORMAT_COMPLETE)
    {
        if (!$this->hasValidFormat()) {
            return false;
        }
        switch ($format) {
            case static::FORMAT_COMPLETE:
                return $this->join(
                    number_format($this->number, 0, null, "."),
                    $this->vn
                );
                break;

            case static::FORMAT_WITH_DASH:
                return $this->join($this->number, $this->vn);
                break;
        }
        return $this->number . $this->vn;
    }
391133
public function formatLocalized($format)
    {
        // Check for Windows to find and replace the %e modifier correctly.
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            $format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format); // @codeCoverageIgnore
        }

        $formatted = strftime($format, strtotime($this->toDateTimeString()));

        return static::$utf8 ? utf8_encode($formatted) : $formatted;
    }
634054
public function getIp($format = self::FORMAT_HEX)
    {
        if ($this->ipHex === null) {
            return null;
        } elseif ($format === self::FORMAT_HEX) {
            return $this->ipHex;
        } elseif ($format === self::FORMAT_IP_STRING) {
            return inet_ntop($this->hex2bin($this->ipHex));
        }
        throw new \Exception('Invalid IP format');
    }
352362
public function format($date, $format)
    {
        if ($date instanceof \DateTimeInterface) {
            return $date->format($format);
        } elseif ($date instanceof \DateInterval) {
            return $date->format($format);
        } elseif ($date === 'now') {
            return date($format);
        } else {
            $timestamp = (integer)$date;
            return date($format, $timestamp);
        }
    }
140753
private function headersFromFormat($format)
	{
		$type = gettype($format);
		if($type === 'array')
		{
			$headers = $format;
		}
		else if($type === 'string')
		{
			$headers = array();
			switch ($format) 
			{
				case 'json':
					$contentType = 'application/json';
					break;
				case 'jsonp':
					$contentType = 'application/javascript';
					break;
				default:
					$contentType = 'text/plain';
					break;
			}
			$headers['Content-Type'] = $contentType;
		}
		return $headers;
	}
1224532
public function format(string $format = null, int $numbers = null)
    {
        $numbers = $numbers === null ? static::getDefaultNumbers() : $numbers;
        $format = $format === null ? static::getToStringFormat() : $format;

        $formatArray = str_split($format);
        $dateString = '';

        foreach ($formatArray as $key => $value)
        {
            if (key_exists($value, $this->values))
            {
                $dateString .= $this->values[$value];
                continue;
            }

            $dateString .= $value;
        }

        if ($numbers === static::INDIAN_NUMBERS)
        {
            $dateString = str_replace($this->arabicNumbers, $this->indianNumbers, $dateString);
        }

        return $dateString;
    }
168711
public function write($format = 'rtf')
	{
		$string = '';
		
		// if $format is a string
		if (is_string($format)) {
			$writer = new Writer();
			$string = $writer->write($this->root, $format);	
		} else {
			throw new \InvalidArgumentException(
				__METHOD__."() expects parameter one, format, to be a string"
			);
		}
		
		return $string;
	}
1303573
public static function format_phone($string = '', $format = null)
	{
		is_null($format) and $format = static::$config['formatting']['phone'];
		return static::format($string, $format);
	}
611576
public function getLocale($format = self::UNDERSCORE)
    {
        $localization = strtolower($this->getLanguage());

        if (null != $this->getCountry()) {
            $country = strtolower($this->getCountry());
            $delimiter = '-';

            switch ($format) {
                case self::UNDERSCORE:
                    $delimiter = '_';
                    break;
                case self::ISO6391:
                    $country = strtoupper($country);
                    break;
                case self::LCID:
                    $delimiter = '_';
                    $country = strtoupper($country);
                    break;
            }

            $localization .= $delimiter . $country;
        }

        return $localization;
    }
874570
public function isFormatNumber($format = null)
    {
        if (null !== $format) {
            $this->formatNumber = (bool) $format;
        }

        return $this->formatNumber;
    }
950625
public function parseCustomFormat($format)
    {
        if (isset($this->parsedFormats[$format])) {
            return $this->parsedFormats[$format];
        }

        return $this->parsedFormats[$format] = $this->parseFormat($format);
    }
205288
public function getFormatInstance($format = null)
    {
        $format = $format ?: $this->format;

        if (!($format instanceof FormatInterface)) {
            if (!isset($this->formats[$format])) {
                $event = new NewFormatEvent($this, new $format($this));
                $this->trigger($event);
                $this->formats[$format] = $event->getFormat();
            }

            $format = $this->formats[$format];
        }

        return $format;
    }
942612
public function format($format = null)
    {
        if ($format !== null) {
            $this->format = $format;
        }

        return $this->format;
    }