/** * This method computes the nth fibonacci number. * * @access public * @static * @param IInteger\Type $n the operand * @return IInteger\Type the result */ public static function fibonacci(IInteger\Type $n) : IInteger\Type { return IInteger\Module::le($n, IInteger\Type::one())->unbox() ? $n : IInteger\Module::add(IInteger\Module::fibonacci(IInteger\Module::decrement($n)), IInteger\Module::fibonacci(IInteger\Module::subtract($n, IInteger\Type::box('2')))); }
/** * This method tests the "decrement" method. * * @dataProvider data_decrement */ public function test_decrement(array $provided, array $expected) { $p0 = IInteger\Module::decrement(IInteger\Type::box($provided[0])); $e0 = $expected[0]; $this->assertInstanceOf('\\Saber\\Data\\IInteger\\Type', $p0); $this->assertSame($e0, $p0->unbox()); }