data mapper POC
[m6w6/pq-gateway] / lib / pq / Mapper / RefProperty.php
diff --git a/lib/pq/Mapper/RefProperty.php b/lib/pq/Mapper/RefProperty.php
new file mode 100644 (file)
index 0000000..d7c6c6f
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+namespace pq\Mapper;
+
+trait RefProperty
+{
+       use Property;
+
+       private $refClass;
+       private $refName;
+
+       function to($class) {
+               $this->refClass = $class;
+               return $this;
+       }
+
+       function references($class) {
+               return $this->refClass === (is_object($class) ? get_class($class) : $class);
+       }
+
+       function by($ref) {
+               $this->refName = $ref;
+               return $this;
+       }
+
+       function on($ref) {
+               return $this->refName === $ref;
+       }
+
+}