From: Andrey Kutejko Date: Tue, 17 Sep 2013 17:41:55 +0000 (+0300) Subject: string tools X-Git-Tag: 0.1~12 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=585d1eb4699ba0474eeabfec046a467061b82906;p=missing-tools.git string tools --- diff --git a/src/stringtools.php b/src/stringtools.php new file mode 100644 index 0000000..871afee --- /dev/null +++ b/src/stringtools.php @@ -0,0 +1,16 @@ +assertTrue(StringTools::startsWith('abcdef', 'abc')); + $this->assertFalse(StringTools::startsWith(' abcdef', 'abc')); + $this->assertFalse(StringTools::startsWith('abc', 'abcdef')); + $this->assertTrue(StringTools::startsWith('abc', 'abc')); + $this->assertTrue(StringTools::startsWith('abc', '')); + $this->assertFalse(StringTools::startsWith('abc', ' ')); + } + + public function testEndsWith() + { + $this->assertTrue(StringTools::endsWith('abcdef', 'def')); + $this->assertFalse(StringTools::endsWith('abcdef ', 'def')); + $this->assertFalse(StringTools::endsWith('abc', 'abcdef')); + $this->assertTrue(StringTools::endsWith('abc', 'abc')); + $this->assertTrue(StringTools::endsWith('abc', '')); + $this->assertFalse(StringTools::endsWith('abc', ' ')); + } +} +