function ProtectedPrivates::privateAdd

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

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.

File

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

Class

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

Namespace

Drupal\phpunit_example

Code

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