eZ\Publish\Core\FieldType\Author\Value::__toString PHP Method

__toString() public method

See also: eZ\Publish\Core\FieldType\Value
public __toString ( )
    public function __toString()
    {
        if (empty($this->authors)) {
            return '';
        }
        $authorNames = array();
        if ($this->authors instanceof AuthorCollection) {
            foreach ($this->authors as $author) {
                $authorNames[] = $author->name;
            }
        }
        return implode(', ', $authorNames);
    }

Usage Example

Example #1
0
 /**
  * @covers \eZ\Publish\Core\FieldType\Author\Value::__toString
  */
 public function testFieldValueToString()
 {
     $value = new AuthorValue($this->authors);
     $authorsName = array();
     foreach ($this->authors as $author) {
         $authorsName[] = $author->name;
     }
     self::assertSame(implode(', ', $authorsName), $value->__toString());
 }