mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-12 00:04:11 +02:00
Update isBase64 to return true if an empty string
This commit is contained in:
@@ -512,8 +512,7 @@ s('دانيال1')->isAlphanumeric(); // true
|
|||||||
|
|
||||||
##### isBase64()
|
##### isBase64()
|
||||||
|
|
||||||
Returns true if the string is base64 encoded, false
|
Returns true if the string is base64 encoded, false otherwise.
|
||||||
otherwise.
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
s('Zm9vYmFy')->isBase64(); // true
|
s('Zm9vYmFy')->isBase64(); // true
|
||||||
|
@@ -635,7 +635,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public function isBase64()
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -2186,7 +2186,7 @@ class StringyTestCase extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(false, ' '),
|
array(false, ' '),
|
||||||
array(false, ''),
|
array(true, ''),
|
||||||
array(true, base64_encode('FooBar') ),
|
array(true, base64_encode('FooBar') ),
|
||||||
array(true, base64_encode(' ') ),
|
array(true, base64_encode(' ') ),
|
||||||
array(true, base64_encode('FÒÔBÀŘ') ),
|
array(true, base64_encode('FÒÔBÀŘ') ),
|
||||||
|
Reference in New Issue
Block a user