public function format(bool $displayCountryForUS = false): string
    {
        $formatter = new NumberFormatter('en', NumberFormatter::CURRENCY);

        if ($displayCountryForUS && $this->currency === 'USD') {
            if ($this->amount >= 0) {
                return 'US' . $formatter->formatCurrency($this->amount, $this->currency);
            }
            return '-US' . $formatter->formatCurrency(-$this->amount, $this->currency);
        }
        return $formatter->formatCurrency($this->amount, $this->currency);
    }
public function format(bool $displayCountryForUS = false): string
    {
        $formatter = new NumberFormatter('en', NumberFormatter::CURRENCY);

        if ($displayCountryForUS && $this->currency === 'USD') {
            if ($this->amount >= 0) {
                return 'US' . $formatter->formatCurrency($this->amount, $this->currency);
            }
            return '-US' . $formatter->formatCurrency(-$this->amount, $this->currency);
        }
        return $formatter->formatCurrency($this->amount, $this->currency);
    }
public function format ( bool $ displayCountryForUS = false ) : string { $ formatter = new NumberFormatter ( 'en' , NumberFormatter :: CURRENCY ) ; if ( $ displayCountryForUS && $ this -> currency === 'USD' ) { if ( $ this -> amount >= 0 ) { return 'US' . $ formatter -> formatCurrency ( $ this -> amount , $ this -> currency ) ; } return '-US' . $ formatter -> formatCurrency ( - $ this -> amount , $ this -> currency ) ; } return $ formatter -> formatCurrency ( $ this -> amount , $ this -> currency ) ; }
Returns a rounded string with the currency symbol

@param bool $displayCountryForUS Set to true if you would like 'US$' instead of just '$'
@return string
Returns a rounded string with the currency symbol