Skip to content

Add minus and plus to BigNumber abstract class. #97

@isfar

Description

@isfar

We have a class like this--

class Math
{
    public static function minimumOf(BigNumber $a, BigNumber $b): BigNumber
    {
        return $a->isLessThanOrEqualTo($b) ? $a : $b;
    }

    public static function maximumOf(BigNumber $a, BigNumber $b): BigNumber
    {
        return $a->isGreaterThanOrEqualTo($b) ? $a : $b;
    }
}

Now, if we pass instances of BigDecimal to minimumOf and want to plus a number to BigNumber that is returned (an instance of BigDecimal, that's not possible because plus and minus don't exist in the abstract class. What I need to do now is call another method in the chain toBigDecimal before being able to do so. It's not clean. I see no problem adding them to the abstract class. What do you say?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions