public function format($value, string $format = null)
    {
        $formatted = number_format(
            $value,
            $this->decimals,
            $format === 'nomask' ? '' : $this->decimal,
            $format === 'nomask' ? '' : $this->thousand
        );

        switch ($format) {
            case 'name':
                $name = $this->name_plural;
                if (!$name || (float) $value === 1.0) {
                    $name = $this->name;
                }
                return $formatted . ' ' . $name;
                break;

            case 'raw':
            case 'nomask':
                return $formatted;
                break;

            case 'symbol':
            default:
                return $this->symbol . ' ' . $formatted;
                break;
        }
    }
public function format($value, string $format = null)
    {
        $formatted = number_format(
            $value,
            $this->decimals,
            $format === 'nomask' ? '' : $this->decimal,
            $format === 'nomask' ? '' : $this->thousand
        );

        switch ($format) {
            case 'name':
                $name = $this->name_plural;
                if (!$name || (float) $value === 1.0) {
                    $name = $this->name;
                }
                return $formatted . ' ' . $name;
                break;

            case 'raw':
            case 'nomask':
                return $formatted;
                break;

            case 'symbol':
            default:
                return $this->symbol . ' ' . $formatted;
                break;
        }
    }
public function format ( $ value , string $ format = null ) { $ formatted = number_format ( $ value , $ this -> decimals , $ format === 'nomask' ? '' : $ this -> decimal , $ format === 'nomask' ? '' : $ this -> thousand ) ; switch ( $ format ) { case 'name' : $ name = $ this -> name_plural ; if ( ! $ name || ( float ) $ value === 1.0 ) { $ name = $ this -> name ; } return $ formatted . ' ' . $ name ; break ; case 'raw' : case 'nomask' : return $ formatted ; break ; case 'symbol' : default : return $ this -> symbol . ' ' . $ formatted ; break ; } }
Outputs a value formatted to this model

@param number $value  Some monetary value to be formatted
@param string $format If should prepend 'symbol' or append 'name', or if
should return without any ('raw'), or even ignore
masks ('nomask')

@return string
Outputs a value formatted to this model