1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-09 06:46:40 +02:00

String is now optional in Stringy constructor

This commit is contained in:
Daniel St. Jules
2015-09-02 23:35:32 -07:00
parent e237f30d94
commit 8f40b3495d
2 changed files with 8 additions and 1 deletions

View File

@@ -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(

View File

@@ -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
*/