From 9e8d993f98c23dccbf93c5aea99bd8cb7a4875d8 Mon Sep 17 00:00:00 2001 From: Thomas Jakobi Date: Fri, 5 Apr 2024 23:38:53 +0200 Subject: [PATCH] add __set_state method and allow to restore the object from i.e. a cache file --- src/Language.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Language.php b/src/Language.php index 12c21bb..fb7c9a6 100644 --- a/src/Language.php +++ b/src/Language.php @@ -36,6 +36,12 @@ public function __construct(string $name, string $code, ?bool $supportsFormality $this->supportsFormality = $supportsFormality; } + public static function __set_state(array $array) + { + $object = new Language($array['name'], $array['code'], $array['supportsFormality']); + return $object; + } + public function __toString(): string { return "$this->name ($this->code)";