Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Gummibeer authored and actions-user committed Oct 20, 2021
1 parent 29407a5 commit 8a396aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ final public static function tryFrom($value): ?Enum
*/
public function __construct($value)
{
if(is_object($value) && method_exists($value, '__toString')) {
if (is_object($value) && method_exists($value, '__toString')) {
$value = (string)$value;
}

Expand Down
12 changes: 8 additions & 4 deletions tests/EnumFromTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace Spatie\Enum\Tests;

use Closure;
use PHPUnit\Framework\TestCase;
use Spatie\Enum\Enum;
use Spatie\Enum\Exceptions\DuplicateValuesException;
use stdClass;
use TypeError;

Expand All @@ -27,12 +25,18 @@ public function from_resolves_all_allowed_value_types()
{
$this->assertTrue(HttpMethod::GET()->equals(HttpMethod::from('GET')));
$this->assertTrue(HttpMethod::GET()->equals(HttpMethod::from(new class {
public function __toString() { return 'GET'; }
public function __toString()
{
return 'GET';
}
})));
$this->assertTrue(HttpMethod::GET()->equals(HttpMethod::from(1)));
$this->assertTrue(HttpMethod::GET()->equals(HttpMethod::from('1')));
$this->assertTrue(HttpMethod::GET()->equals(HttpMethod::from(new class {
public function __toString() { return '1'; }
public function __toString()
{
return '1';
}
})));
}

Expand Down

0 comments on commit 8a396aa

Please sign in to comment.