function ProtectedPrivates::protectedAdd

Same name in other branches
  1. 3.x modules/phpunit_example/src/ProtectedPrivates.php \Drupal\phpunit_example\ProtectedPrivates::protectedAdd()

A simple addition method with validity checking.

Parameters

int|float $a: A number to add.

int|float $b: Another number to add.

Return value

int|float The sum of $a and $b.

Throws

\InvalidArgumentException If either $a or $b is non-numeric, we can't add, so we throw.

1 call to ProtectedPrivates::protectedAdd()
ProtectedPrivatesSubclass::subclassProtectedAdd in modules/phpunit_example/tests/src/Unit/Subclasses/ProtectedPrivatesSubclass.php
A stub class so we can access a protected method.

File

modules/phpunit_example/src/ProtectedPrivates.php, line 33

Class

ProtectedPrivates
A class with features to show how to do unit testing.

Namespace

Drupal\phpunit_example

Code

protected function protectedAdd($a, $b) {
    $adder = new AddClass();
    return $adder->add($a, $b);
}