echo "{$tA}({$p1}) {$op} {$tB}({$p2}) = {$tR}({$res})" . PHP_EOL; } else { echo "{$op}({$tA}({$p1})) = {$tR}({$res})" . PHP_EOL; } } catch (InvalidTypeException $e) { $msg = $e->getMessage(); echo "{$tA}({$p1}) {$op} {$tB}({$p2}) is invalid: {$msg}" . PHP_EOL; } } $iphp = 19; $fphp = 13.27; $i = F::create('int', 6); $w = F::create('whole', 21); $n = F::create('natural', 13); $f = F::create('float', 2.26); $r = F::Create('rational', '2/3'); $c = F::create('complex', '2+6i'); $items = [$iphp, $i, $w, $n, $fphp, $f, $r, $c]; echo "Library supported arithmetic operations and return types\n"; echo "Non complex numbers\n"; echo "Addition\n\n"; foreach ($items as $a) { foreach ($items as $b) { display('add', $a, $b); } } echo "\nSubtraction\n\n"; foreach ($items as $a) { foreach ($items as $b) { display('sub', $a, $b); }