PluginProbe
Elementor Website Builder – more than just a page builder / 3.25.1
Elementor Website Builder – more than just a page builder v3.25.1
4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 All 455 releases
elementor / vendor_prefixed / laravel / serializable-closure / src / Serializers / Signed.php

Signed.php in Elementor Website Builder – more than just a page builder 3.25.1, at vendor_prefixed/laravel/serializable-closure/src/Serializers/Signed.php

80 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ElementorDeps\Laravel\SerializableClosure\Serializers;
4
5 use ElementorDeps\Laravel\SerializableClosure\Contracts\Serializable;
6 use ElementorDeps\Laravel\SerializableClosure\Exceptions\InvalidSignatureException;
7 use ElementorDeps\Laravel\SerializableClosure\Exceptions\MissingSecretKeyException;
8 class Signed implements Serializable
9 {
10 /**
11 * The signer that will sign and verify the closure's signature.
12 *
13 * @var \Laravel\SerializableClosure\Contracts\Signer|null
14 */
15 public static $signer;
16 /**
17 * The closure to be serialized/unserialized.
18 *
19 * @var \Closure
20 */
21 protected $closure;
22 /**
23 * Creates a new serializable closure instance.
24 *
25 * @param \Closure $closure
26 * @return void
27 */
28 public function __construct($closure)
29 {
30 $this->closure = $closure;
31 }
32 /**
33 * Resolve the closure with the given arguments.
34 *
35 * @return mixed
36 */
37 public function __invoke()
38 {
39 return \call_user_func_array($this->closure, \func_get_args());
40 }
41 /**
42 * Gets the closure.
43 *
44 * @return \Closure
45 */
46 public function getClosure()
47 {
48 return $this->closure;
49 }
50 /**
51 * Get the serializable representation of the closure.
52 *
53 * @return array
54 */
55 public function __serialize()
56 {
57 if (!static::$signer) {
58 throw new MissingSecretKeyException();
59 }
60 return static::$signer->sign(\serialize(new Native($this->closure)));
61 }
62 /**
63 * Restore the closure after serialization.
64 *
65 * @param array $signature
66 * @return void
67 *
68 * @throws \Laravel\SerializableClosure\Exceptions\InvalidSignatureException
69 */
70 public function __unserialize($signature)
71 {
72 if (static::$signer && !static::$signer->verify($signature)) {
73 throw new InvalidSignatureException();
74 }
75 /** @var \Laravel\SerializableClosure\Contracts\Serializable $serializable */
76 $serializable = \unserialize($signature['serializable']);
77 $this->closure = $serializable->getClosure();
78 }
79 }
80