mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-09 23:06:41 +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
|
* @throws \InvalidArgumentException if an array or object without a
|
||||||
* __toString method is passed as the first argument
|
* __toString method is passed as the first argument
|
||||||
*/
|
*/
|
||||||
public function __construct($str, $encoding = null)
|
public function __construct($str = '', $encoding = null)
|
||||||
{
|
{
|
||||||
if (is_array($str)) {
|
if (is_array($str)) {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
|
@@ -24,6 +24,13 @@ class StringyTestCase extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('UTF-8', $stringy->getEncoding());
|
$this->assertEquals('UTF-8', $stringy->getEncoding());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEmptyConstruct()
|
||||||
|
{
|
||||||
|
$stringy = new S();
|
||||||
|
$this->assertStringy($stringy);
|
||||||
|
$this->assertEquals('', (string) $stringy);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException InvalidArgumentException
|
* @expectedException InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user