@@ 34-43 (lines=10) @@ | ||
31 | * @param Context|callable $context |
|
32 | * @return static |
|
33 | */ |
|
34 | public static function fromArray(array $data, $context = null) |
|
35 | { |
|
36 | if (isset($data['code'])) { |
|
37 | $className = '\Commercetools\Core\Error\\' . ucfirst($data['code']) . 'Error'; |
|
38 | if (class_exists($className)) { |
|
39 | return new $className($data, $context); |
|
40 | } |
|
41 | } |
|
42 | return new static($data, $context); |
|
43 | } |
|
44 | } |
|
45 |
@@ 66-75 (lines=10) @@ | ||
63 | * @param Context|callable $context |
|
64 | * @return static |
|
65 | */ |
|
66 | public static function fromArray(array $data, $context = null) |
|
67 | { |
|
68 | if (isset($data['type'])) { |
|
69 | $className = '\Commercetools\Core\Model\Message\\' . ucfirst($data['type']) . 'Message'; |
|
70 | if (class_exists($className)) { |
|
71 | return new $className($data, $context); |
|
72 | } |
|
73 | } |
|
74 | return new static($data, $context); |
|
75 | } |
|
76 | } |
|
77 |