Disaster: the front page says the festival is canceled! Léo has struck again, and one line was all it took to change a title after the fact. A published article should not move anymore, and nobody outside the class has any business touching its text.
Your mission
- Make every property of
Articleread-only withreadonly, then delete Léo's line, which now makes the page crash. - Make the text private:
private readonly string $texte. - Add a public method
chapo(): string(standfirst) toArticle, which returns the standfirst: the first 80 characters followed by “…” for a long text, the whole text otherwise. - In
afficherArticle(), use$article->chapo().
Reminder
public, private: visibility says who may touch a property or call a method. readonly forbids changing a value after construction. A method is a function that lives in the class; there, it reaches the object through $this. That is the idea of encapsulation: the class keeps its data to itself, and offers methods to work with it.