From 585d1eb4699ba0474eeabfec046a467061b82906 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Tue, 17 Sep 2013 20:41:55 +0300 Subject: [PATCH] string tools --- src/stringtools.php | 16 ++++++++++++++++ t/StringTest.php | 25 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/stringtools.php create mode 100644 t/StringTest.php 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', ' ')); + } +} + -- 2.49.0