Permalink
Browse files

correcting __toString method

  • Loading branch information...
1 parent d7ed1ff commit 2299cc7ca3558e5bc9f128cc5658ee5a6917cb11 Jonthan Moss committed May 31, 2011
Showing with 25 additions and 1 deletion.
  1. +12 −0 src/morph/property/ComposeMany.php
  2. +1 −1 src/morph/property/Generic.php
  3. +12 −0 src/morph/property/HasMany.php
@@ -92,6 +92,18 @@ public function __getRawValue()
}
return $rawValue;
}
+
+ /**
+ * @return string
+ */
+ public function __toString()
+ {
+ $segments = array();
+ foreach ($this->getValue() as $object) {
+ $segments[] = $object->__toString();
+ }
+ return implode("\n", $segments);
+ }
/**
*
@@ -104,6 +104,6 @@ public function __setRawValue($value)
*/
public function __toString()
{
- return $this->getValue();
+ return (string)$this->getValue();
}
}
@@ -126,4 +126,16 @@ private function loadFromReferences()
}
$this->loaded = true;
}
+
+ /**
+ * @return string
+ */
+ public function __toString()
+ {
+ $segments = array();
+ foreach ($this->getValue() as $object) {
+ $segments[] = $object->__toString();
+ }
+ return implode("\n", $segments);
+ }
}

0 comments on commit 2299cc7

Please sign in to comment.