diff --git a/exercises/accumulate/example.php b/exercises/accumulate/example.php index b1b571bb9..98cf14e3c 100644 --- a/exercises/accumulate/example.php +++ b/exercises/accumulate/example.php @@ -1,11 +1,13 @@ assertEquals( $expected, accumulate($chars, function ($char) use ($digits) { return accumulate($digits, function ($digit) use ($char) { - return $char.$digit; + return $char . $digit; }); }) ); @@ -77,12 +91,12 @@ public function testAccumulateUsingBuiltInFunction() : void public function testAccumulateUsingStaticMethod() : void { - $this->assertEquals([5, 6], accumulate(['Hello', 'World!'], 'Str::len')); + $this->assertEquals([5, 6], accumulate(['Hello', 'World!'], 'ExercismTest\Accumulate\Str::len')); } public function testAccumulateUsingInvoke() : void { - $this->assertEquals([['f', 'o', 'o']], accumulate(['foo'], new StrSpliter())); + $this->assertEquals([['f', 'o', 'o']], accumulate(['foo'], new StrSplitter())); } public function testAccumulateUsingObjectAndArrayNotation() : void @@ -90,27 +104,3 @@ public function testAccumulateUsingObjectAndArrayNotation() : void $this->assertEquals([true, false, false], accumulate(['Yes', 0, []], [new Is(), 'truthy'])); } } - -class Str -{ - public static function len($string) : int - { - return strlen($string); - } -} - -class StrSpliter -{ - public function __invoke($value) - { - return str_split($value); - } -} - -class Is -{ - public function truthy($value) : bool - { - return $value ? true : false; - } -} diff --git a/exercises/accumulate/test/Is.php b/exercises/accumulate/test/Is.php new file mode 100644 index 000000000..970d2f6c3 --- /dev/null +++ b/exercises/accumulate/test/Is.php @@ -0,0 +1,11 @@ +