Permalink
Browse files

__clone added to the Object class

  • Loading branch information...
1 parent a5a2d94 commit 4e7b20505429a9a60c6ca4a1cf349429449c853a @kkamkou kkamkou committed Mar 5, 2012
Showing with 23 additions and 18 deletions.
  1. +23 −18 src/morph/Object.php
View
@@ -37,8 +37,7 @@ class Object
protected $validators;
/**
- * @param string $id If supplied this will be the id used to reference this object
- * @return Morph_Object
+ * @param string $id If supplied this will be the id used to reference this object
*/
public function __construct($id = null)
{
@@ -92,8 +91,8 @@ public function state()
/**
* Adds a new property to this object
*
- * @param Morph_Property_Generic $property
- * @param string $alias
+ * @param \morph\property\Generic $property
+ * @param string $alias (Default: null)
* @return \morph\Object
*/
protected function addProperty(\morph\property\Generic $property, $alias = null)
@@ -108,9 +107,9 @@ protected function addProperty(\morph\property\Generic $property, $alias = null)
/**
* Sets the property data for this object
*
- * @param $data
- * @param $state
- * @return Morph_Object
+ * @param array $data
+ * @param string $state (Default: Enum::STATE_DIRTY)
+ * @return \morph\Object
*/
public function __setData(array $data, $state = Enum::STATE_DIRTY)
{
@@ -159,7 +158,6 @@ public function __getPropertySet()
// ********************** //
/**
- *
* @param $propertyName
* @return mixed
*/
@@ -175,10 +173,9 @@ public function __get($propertyName)
}
/**
- *
- * @param $propertyName
- * @param $propertyValue
- * @return Morph_Object
+ * @param string $propertyName
+ * @param string $propertyValue
+ * @return \morph\Object
*/
public function __set($propertyName, $propertyValue)
{
@@ -191,15 +188,23 @@ public function __set($propertyName, $propertyValue)
return $this;
}
+ /**
+ * Clones the current object
+ */
+ public function __clone()
+ {
+ $this->id = null;
+ }
+
// ********************* //
// PERSISTANCE FUNCTIONS //
// ********************* //
/**
* Saves this object
*
- * @param array $options Support the same options as MongoCollection::save()
- * @return Morph_Object
+ * @param array $options Support the same options as MongoCollection::save()
+ * @return \morph\Object
*/
public function save(array $options = array())
{
@@ -289,17 +294,17 @@ public function delete()
*/
public function __toString()
{
- // create the array that we will be encoding and returning
- // also put inside the array the mongodb ID and the 'state'
+ // create the array that we will be encoding and returning
+ // also put inside the array the mongodb ID and the 'state'
$data = array(
'Id' => $this->id(),
'State' => $this->state()
);
- // iterate through all the properties this object has and print them out
+ // iterate through all the properties this object has and print them out
foreach ($this->propertySet as $name => $property) {
$data[$name] = (string)$property;
- }
+ }
return \json_encode($data);
}

0 comments on commit 4e7b205

Please sign in to comment.