We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3b5b841 commit 8cec8fcCopy full SHA for 8cec8fc
1 file changed
src/Libraries/CurlDeserializer.php
@@ -0,0 +1,24 @@
1
+<?php
2
+
3
+namespace Nurigo\Solapi\Libraries;
4
5
+use ReflectionObject;
6
+use stdClass;
7
8
+trait CurlDeserializer
9
+{
10
+ static function deserialize(stdClass $object): self
11
+ {
12
+ $deserializedClass = new self();
13
+ $reflectionObject = new ReflectionObject($object);
14
+ $reflectionProperties = $reflectionObject->getProperties();
15
+ foreach ($reflectionProperties as $reflectionProperty) {
16
+ $name = $reflectionProperty->getName();
17
+ if (property_exists(self::class, $name)) {
18
+ $deserializedClass->{$name} = $object->$name;
19
+ }
20
21
+ unset($object);
22
+ return $deserializedClass;
23
24
+}
0 commit comments