Hello,
I am doing coding exercises through the book that teaches about PHP OOP.
I am given the task to create a concrete method in the abstract class to set the number of articles. The way I have done differs from the solution but it works.
My question is, is there something important (a concept or notion) I’ve missed by not doing as it was depicted in the solution?
Thanks!
The way I have done it:
public function setNumberOfArticles($int)
{
$this->numberOfArticles = $int;
}
The way it is done in the solution:
public function setNumberOfArticles($int)
{
// Cast to integer type
$numberOfArticles = (int)$int;
$this->numberOfArticles = $numberOfArticles;
}
P.S.
I am using PHPStorm