news
news copied to clipboard
Inconsistency in news model datetime getter methods
There is a slight inconsistency in the way that days, months and years can be derived in the news model.
// File: EXT:news/Classes/Domain/Model/News.php
// Lines: 359 through 387
/**
* Get year of datetime
*
* @return false|string
*/
public function getYearOfDatetime()
{
return $this->getDatetime()->format('Y');
}
/**
* Get month of datetime
*
* @return false|string
*/
public function getMonthOfDatetime()
{
return $this->getDatetime()->format('m');
}
/**
* Get day of datetime
*
* @return int
*/
public function getDayOfDatetime(): int
{
return (int)$this->datetime->format('d');
}
Both the methods getYearOfDatetime
and getMonthOfDatetime
get the datetime information via getDatetime
method, whilst the getDayOfDatetime
method derives this data directly by access to the datetime
property.
This seems inconsistent to me. I'd rather let all of them access the data either directly through the property or via the getter method. Maybe there is a reason for that. Georg will know.