This implementation follows the JavaScript specification for "substring".
Examples::
String.substring('Hello, World!', 7, 12) == 'World'
String.substring('Hello, World!', 7) == 'World!'
/** * @test * @dataProvider substringExamples */ public function substringWorks($string, $start, $end, $expected) { $helper = new StringHelper(); $result = $helper->substring($string, $start, $end); $this->assertSame($expected, $result); }