Skip to content

Catching 'Divide By Zero Error' and Formatting #8

Description

@jamesmills

Howdy @mattiasgeniar

Firstly, thanks for this package, saved me some time!

Nothing urgent here... I just found myself having to wrap around your function with the below to catch and format. Not sure if this is helpful for any additional feature ideas or not but thought I would share anyway.

    function percentageWrapper($a, $b, $round = true, $symbol = true)
    {
        if ($a <= 0 || $b <= 0) {
            $percentage = 0;
        } else {
            $percentage = percentage($a, $b);
        }

        if ($round) {
            $percentage = round($percentage);
        }

        if ($symbol) {
            $percentage .= '%';
        }

        return $percentage;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions