-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade ValidatedDTO * Fix tests * Optimize * Cs Fix --------- Co-authored-by: Deeka Wong <[email protected]>
- Loading branch information
1 parent
eb575e3
commit 24b9b34
Showing
6 changed files
with
535 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of friendsofhyperf/components. | ||
* | ||
* @link https://github.com/friendsofhyperf/components | ||
* @document https://github.com/friendsofhyperf/components/blob/main/README.md | ||
* @contact [email protected] | ||
*/ | ||
return [ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| REQUIRE CASTING | ||
|-------------------------------------------------------------------------- | ||
| | ||
| If this is set to true, you must configure a cast type for all properties of your DTOs. | ||
| If a property doesn't have a cast type configured it will throw a | ||
| \FriendsOfHyperf\ValidatedDTO\Exceptions\MissingCastTypeException exception | ||
| | ||
*/ | ||
'require_casting' => false, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of friendsofhyperf/components. | ||
* | ||
* @link https://github.com/friendsofhyperf/components | ||
* @document https://github.com/friendsofhyperf/components/blob/main/README.md | ||
* @contact [email protected] | ||
*/ | ||
namespace FriendsOfHyperf\ValidatedDTO\Concerns; | ||
|
||
use stdClass; | ||
|
||
trait Wireable | ||
{ | ||
public static function fromLivewire($value) | ||
{ | ||
if (is_array($value)) { | ||
return new static($value); | ||
} | ||
|
||
if (is_object($value) && method_exists($value, 'toArray')) { | ||
return new static($value->toArray()); | ||
} | ||
|
||
if ($value instanceof stdClass) { | ||
return new static((array) $value); | ||
} | ||
|
||
return new static([]); | ||
} | ||
|
||
public function toLivewire(): array | ||
{ | ||
return $this->toArray(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.