diff --git a/src/Stringy.php b/src/Stringy.php index 73b3f2f..63dcbd8 100644 --- a/src/Stringy.php +++ b/src/Stringy.php @@ -31,7 +31,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess * @throws \InvalidArgumentException if an array or object without a * __toString method is passed as the first argument */ - public function __construct($str, $encoding = null) + public function __construct($str = '', $encoding = null) { if (is_array($str)) { throw new \InvalidArgumentException( diff --git a/tests/StringyTest.php b/tests/StringyTest.php index 47b825d..03ef5fb 100644 --- a/tests/StringyTest.php +++ b/tests/StringyTest.php @@ -24,6 +24,13 @@ class StringyTestCase extends PHPUnit_Framework_TestCase $this->assertEquals('UTF-8', $stringy->getEncoding()); } + public function testEmptyConstruct() + { + $stringy = new S(); + $this->assertStringy($stringy); + $this->assertEquals('', (string) $stringy); + } + /** * @expectedException InvalidArgumentException */