<?php
abstract class AbstractDomainObject
{
protected $id = null;
/**
* Id
*/
public function setId($id)
{
if (!is_null($this->id)) {
throw new Exception('This object already has an id set and it can not be changed. Use the data mapper to create a new domain object.');
}
$this->id = $id;
return $this;
}
public function getId()
{
return $this->id;
}
}
class Article extends AbstractDomainObject
{
protected $title = null;
protected $published = null;
protected $content = null;
/**
* Title
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
public function getTitle()
{
return $this->title;
}
/**
* Published at
*/
public function setPublished($published)
{
$this->published = $published;
return $this;
}
public function getPublished()
{
return $this->published;
}
/**
* Content
*/
public function setContent($content)
{
$this->content = $content;
return $this;
}
public function getContent()
{
return $this->content;
}
}
class Test
{
public function __construct(AbstractDomainObject $t) {
}
}
$test = new Test(new Article());
?>