diff --git a/src/Extensions/Extension.php b/src/Extensions/Extension.php index 7de2f23..420b9c1 100644 --- a/src/Extensions/Extension.php +++ b/src/Extensions/Extension.php @@ -43,6 +43,7 @@ protected function pickArrayRandomElements(array $array, int $elements = 1) protected function pickArrayRandomElement(array $array) { $elements = $this->pickArrayRandomElements($array); + return reset($elements); } } diff --git a/tests/Unit/Extensions/ExtensionTest.php b/tests/Unit/Extensions/ExtensionTest.php index 461f0a3..a10af17 100644 --- a/tests/Unit/Extensions/ExtensionTest.php +++ b/tests/Unit/Extensions/ExtensionTest.php @@ -35,7 +35,7 @@ public function testExtensionPickArrayRandomElements(): void $elements = range(1, 100); $method = (new ReflectionClass(Extension::class))->getMethod('pickArrayRandomElements'); - $result = $method->invoke(new Extension(new Randomizer), $elements, 5); + $result = $method->invoke(new Extension(new Randomizer()), $elements, 5); $this->assertCount( 5, @@ -53,7 +53,7 @@ public function testExtensionPickArrayRandomElement(): void $elements = range(1, 100); $method = (new ReflectionClass(Extension::class))->getMethod('pickArrayRandomElement'); - $result = $method->invoke(new Extension(new Randomizer), $elements); + $result = $method->invoke(new Extension(new Randomizer()), $elements); $this->assertIsNotArray($result); $this->assertGreaterThanOrEqual(1, $result);