-
-
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.
- Loading branch information
Adrien Loyant
committed
Sep 19, 2024
1 parent
93497e2
commit e485250
Showing
7 changed files
with
131 additions
and
101 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
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
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
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,83 @@ | ||
<?php | ||
|
||
/** | ||
* Part of SplTypes package. | ||
* | ||
* (c) Adrien Loyant <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Ducks\Component\SplTypes; | ||
|
||
/** | ||
* Trait used for magic | ||
*/ | ||
trait SplTypeTrait | ||
{ | ||
/** | ||
* Internal enum value. | ||
* | ||
* @var mixed | ||
*/ | ||
// phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore | ||
protected $__default; | ||
|
||
/** | ||
* Serialize object. | ||
* | ||
* @return array<string,mixed> | ||
*/ | ||
final public function __serialize(): array | ||
{ | ||
return [ | ||
'__default' => $this->__default, | ||
]; | ||
} | ||
|
||
/** | ||
* Unserialize object. | ||
* | ||
* @param array<string,mixed> $data | ||
* @return void | ||
*/ | ||
final public function __unserialize(array $data): void | ||
{ | ||
$this->__default = $data['__default']; | ||
} | ||
|
||
/** | ||
* Stringify object. | ||
* | ||
* @return string | ||
*/ | ||
final public function __toString(): string | ||
{ | ||
return (string) $this->__default; | ||
} | ||
|
||
/** | ||
* Export object. | ||
* | ||
* @param array<mixed,mixed> $properties | ||
* | ||
* @return SplType | ||
*/ | ||
final public static function __set_state(array $properties): object | ||
{ | ||
return new static($properties['__default']); | ||
} | ||
|
||
/** | ||
* Dumping object. | ||
* | ||
* @return array<string,mixed> | ||
*/ | ||
final public function __debugInfo(): array | ||
{ | ||
return [ | ||
'__default' => $this->__default, | ||
]; | ||
} | ||
} |