diff --git a/includes/class-PageYear.php b/includes/class-PageYear.php index 32709d3..bc0a82e 100644 --- a/includes/class-PageYear.php +++ b/includes/class-PageYear.php @@ -1,60 +1,60 @@ . namespace itwikidelbot; /** * Abstraction of a page related to a year */ abstract class PageYear extends PageTemplated { /** * Year * * @var int */ private $year; /** * Constructor * * @param $year int * @see PageTemplated::__construct() */ public function __construct( $year ) { - $this->year = $year; + $this->year = (int) $year; parent::__construct(); } /** * Get the year * * @return int */ public function getYear() { return $this->year; } /** * Template arguments * * @override CategoryTemplated::getTemplateArguments() */ public function getTemplateArguments() { return [ $this->getYear() ]; } } diff --git a/includes/class-PageYearMonth.php b/includes/class-PageYearMonth.php index e4bdfac..2f6713e 100644 --- a/includes/class-PageYearMonth.php +++ b/includes/class-PageYearMonth.php @@ -1,73 +1,73 @@ . namespace itwikidelbot; /** * Abstraction of a page related to a month (in a certain year) */ abstract class PageYearMonth extends PageYear { /** * Month * * @var int 1-12 */ private $month; /** * Constructor * * @param $year int * @param $month int 1-12 * @see PageYear::__construct() */ public function __construct( $year, $month ) { - $this->month = $month; + $this->month = (int) $month; parent::__construct( $year ); } /** * Get the month * * @return int 1-12 */ public function getMonth() { return $this->month; } /** * Get the month name * * @return string e.g. 'aprile' */ public function getMonthName() { return Months::number2name( $this->getMonth() - 1 ); } /** * Template arguments * * @override PageYear::getTemplateArguments() */ public function getTemplateArguments() { return array_merge( parent::getTemplateArguments(), [ $this->getMonth(), Months::number2name( $this->getMonth() - 1 ), ] ); } } diff --git a/includes/class-PageYearMonthDay.php b/includes/class-PageYearMonthDay.php index 379d4ba..27979b0 100644 --- a/includes/class-PageYearMonthDay.php +++ b/includes/class-PageYearMonthDay.php @@ -1,89 +1,89 @@ . namespace itwikidelbot; use DateTime; /** * Abstraction of a page related to a day (in a certain month of a certain year) */ abstract class PageYearMonthDay extends PageYearMonth { /** * Day * * @var int 1-31 */ private $day; /** * Constructor * * @param $year int * @param $month int 1-12 * @param $day int 1-31 * @see PageYearMonth::__construct() */ public function __construct( $year, $month, $day ) { - $this->day = $day; + $this->day = (int) $day; parent::__construct( $year, $month ); } /** * Static constructor * * @param $date_time DateTime */ public static function createFromDateTime( DateTime $datetime ) { return new self( $datetime->format('Y'), $datetime->format('m'), $datetime->format('d') ); } /** * Get the day * * @return int 1-13 */ public function getDay() { return $this->day; } /** * Get a DateTime object * * @return DateTime */ public function getDateTime() { return DateTime::createFromFormat( 'Y-m-d', sprintf( '%d-%d-%d', $this->getYear(), $this->getMonth(), $this->getDay() ) ); } /** * Template arguments * * @override PageYearMonth::getTemplateArguments() */ public function getTemplateArguments() { return array_merge( parent::getTemplateArguments(), [ $this->getDay() ] ); } }