elementor
/
vendor_prefixed
/
laravel
/
serializable-closure
/
src
/
UnsignedSerializableClosure.php
UnsignedSerializableClosure.php in Elementor Website Builder – more than just a page builder 3.25.1, at vendor_prefixed/laravel/serializable-closure/src/UnsignedSerializableClosure.php
| 1 | <?php |
| 2 | |
| 3 | namespace ElementorDeps\Laravel\SerializableClosure; |
| 4 | |
| 5 | use Closure; |
| 6 | use ElementorDeps\Laravel\SerializableClosure\Exceptions\PhpVersionNotSupportedException; |
| 7 | class UnsignedSerializableClosure |
| 8 | { |
| 9 | /** |
| 10 | * The closure's serializable. |
| 11 | * |
| 12 | * @var \Laravel\SerializableClosure\Contracts\Serializable |
| 13 | */ |
| 14 | protected $serializable; |
| 15 | /** |
| 16 | * Creates a new serializable closure instance. |
| 17 | * |
| 18 | * @param \Closure $closure |
| 19 | * @return void |
| 20 | */ |
| 21 | public function __construct(Closure $closure) |
| 22 | { |
| 23 | if (\PHP_VERSION_ID < 70400) { |
| 24 | throw new PhpVersionNotSupportedException(); |
| 25 | } |
| 26 | $this->serializable = new Serializers\Native($closure); |
| 27 | } |
| 28 | /** |
| 29 | * Resolve the closure with the given arguments. |
| 30 | * |
| 31 | * @return mixed |
| 32 | */ |
| 33 | public function __invoke() |
| 34 | { |
| 35 | if (\PHP_VERSION_ID < 70400) { |
| 36 | throw new PhpVersionNotSupportedException(); |
| 37 | } |
| 38 | return \call_user_func_array($this->serializable, \func_get_args()); |
| 39 | } |
| 40 | /** |
| 41 | * Gets the closure. |
| 42 | * |
| 43 | * @return \Closure |
| 44 | */ |
| 45 | public function getClosure() |
| 46 | { |
| 47 | if (\PHP_VERSION_ID < 70400) { |
| 48 | throw new PhpVersionNotSupportedException(); |
| 49 | } |
| 50 | return $this->serializable->getClosure(); |
| 51 | } |
| 52 | /** |
| 53 | * Get the serializable representation of the closure. |
| 54 | * |
| 55 | * @return array |
| 56 | */ |
| 57 | public function __serialize() |
| 58 | { |
| 59 | return ['serializable' => $this->serializable]; |
| 60 | } |
| 61 | /** |
| 62 | * Restore the closure after serialization. |
| 63 | * |
| 64 | * @param array $data |
| 65 | * @return void |
| 66 | */ |
| 67 | public function __unserialize($data) |
| 68 | { |
| 69 | $this->serializable = $data['serializable']; |
| 70 | } |
| 71 | } |
| 72 |