|
|
@@ -0,0 +1,57 @@
|
|
|
+<?php
|
|
|
+namespace Workerman;
|
|
|
+
|
|
|
+Trait Properties
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * Properties.
|
|
|
+ *
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
+ public $properties = [];
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Setter.
|
|
|
+ *
|
|
|
+ * @param string $name
|
|
|
+ * @param mixed $value
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function __set($name, $value)
|
|
|
+ {
|
|
|
+ $this->properties[$name] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Getter.
|
|
|
+ *
|
|
|
+ * @param string $name
|
|
|
+ * @return mixed|null
|
|
|
+ */
|
|
|
+ public function __get($name)
|
|
|
+ {
|
|
|
+ return $this->properties[$name] ?? null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Isset.
|
|
|
+ *
|
|
|
+ * @param string $name
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function __isset($name)
|
|
|
+ {
|
|
|
+ return isset($this->properties[$name]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Unset.
|
|
|
+ *
|
|
|
+ * @param string $name
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function __unset($name)
|
|
|
+ {
|
|
|
+ unset($this->properties[$name]);
|
|
|
+ }
|
|
|
+}
|