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:
@@ -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(
|
||||
|
@@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user