HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/beat-the-barn.komma.nl/app/Base/PriceTrait.php
<?php


namespace App\Base;


trait PriceTrait
{
    public function getPrice(): string
    {
        // Splice on decimal divider
        $explodePrice = explode('.', (string) ($this->price / 100));

        // If whole number so $explodePrice[1] is not set, add the '-'
        if(!isset($explodePrice[1])) $decimal = '-';
        else {
            if(strlen($explodePrice[1]) == 1) $decimal = $explodePrice[1] . '0';
            else $decimal = $explodePrice[1];
        }

        return $explodePrice[0] . ',' . $decimal;
    }
}