I have following classes:
class Author {
public $id;
public $name;
}
class Article {
protected $author; // Author
protected $title; // String
public function __construct(Author $author, string $title)
$this->author = $author;
$this->title = $title;
}
}
Please help to implement these functionalities by using a proper pattern:
-
Each
Author
should represent a list of articles (ArticleList
) may be something like this?class ArticleList { private $articles = []; public function addArticle(Article $article) { $this->articles[] = $article; } }
-
Change the
Author
of anArticle
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire