1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-09 14:56:31 +02:00

Update isBase64 to return true if an empty string

This commit is contained in:
Daniel St. Jules
2015-12-20 11:46:33 -08:00
parent 318db789b1
commit d990a41a1a
3 changed files with 3 additions and 4 deletions

View File

@@ -512,8 +512,7 @@ s('دانيال1')->isAlphanumeric(); // true
##### isBase64()
Returns true if the string is base64 encoded, false
otherwise.
Returns true if the string is base64 encoded, false otherwise.
```php
s('Zm9vYmFy')->isBase64(); // true

View File

@@ -635,7 +635,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
*/
public function isBase64()
{
return $this->str !== '' && ( base64_encode( base64_decode( $this->str, true ) ) === $this->str );
return (base64_encode(base64_decode($this->str, true)) === $this->str);
}
/**

View File

@@ -2186,7 +2186,7 @@ class StringyTestCase extends PHPUnit_Framework_TestCase
{
return array(
array(false, ' '),
array(false, ''),
array(true, ''),
array(true, base64_encode('FooBar') ),
array(true, base64_encode(' ') ),
array(true, base64_encode('FÒÔBÀŘ') ),