Gaston finally agreed to sign the article about the mayor's cat. Readers, for their part, want to know who is talking to them. Madame Lou would like each article to be signed with the name and the role of its author: “By Gaston, village constable”.
Your mission
- Declare an
Auteur(author) class whose constructor receivesstring $nom(name) andstring $role, both read-only, and asignature(): string(byline) method that returns “Gaston, village constable”. - Create each of the three authors only once, in variables: Madame Lou (“editor-in-chief”), Gaston (“village constable”) and Odette (“baker”).
- The
auteurproperty ofArticlebecomes anAuteur. Give each article its own. The article about the mayor's cat, signed “the newsroom” until now, is now by Gaston. - In
afficherArticle(), sign each article withByfollowed by its author's byline: “By Gaston, village constable”. Every article now has an author, so the “By the newsroom” case goes away.
Reminder
A property can hold another object: this is called composition. The article does not copy Gaston's name, it points to Gaston. If Gaston changes roles, both of his articles follow. Arrows can be chained: $article->auteur->signature().