diff --git a/includes/class-CategoryYear.php b/includes/class-CategoryYear.php index 42d7f18..51ddf62 100644 --- a/includes/class-CategoryYear.php +++ b/includes/class-CategoryYear.php @@ -1,75 +1,48 @@ . namespace itwikidelbot; /** * Handle a yearly category * * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_-_2017 */ -class CategoryYear extends PageTemplated { +class CategoryYear extends PageYear { /** * Template name of this category * * @override CategoryTemplated::TEMPLATE_NAME */ const TEMPLATE_NAME = 'CATEGORY_YEAR'; - /** - * Year - * - * @var int - */ - private $year; - - /** - * Constructor - * - * @param $year int - * @see CategoryTemplated::__construct() - */ - public function __construct( $year ) { - $this->year = $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-CategoryYearMonth.php b/includes/class-CategoryYearMonth.php index f55989b..c898840 100644 --- a/includes/class-CategoryYearMonth.php +++ b/includes/class-CategoryYearMonth.php @@ -1,82 +1,54 @@ . namespace itwikidelbot; /** * Handle a monthly category * * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_-_aprile_2018 */ -class CategoryYearMonth extends CategoryYear { +class CategoryYearMonth extends PageYearMonth { /** * Template name of this category * * @override CategoryTemplated::TEMPLATE_NAME */ const TEMPLATE_NAME = 'CATEGORY_MONTH'; - /** - * Month - * - * @var int 1-12 - */ - private $month; - - /** - * Constructor - * - * @param $year int - * @param $month int 1-12 - * @see CategoryYear::__construct() - */ - public function __construct( $year, $month ) { - $this->month = $month; - parent::__construct( $year ); - } - - /** - * Get the month - * - * @return int 1-12 - */ - public function getMonth() { - return $this->month; - } - /** * Template arguments * * @override CategoryTemplated::getTemplateArguments() */ public function getTemplateArguments() { return [ - ( new parent( $this->getYear() ) ) + ( new CategoryYear( $this->getYear() ) ) ->getTemplatedTitle(), $this->getYear(), $this->getMonth(), Months::number2name( $this->getMonth() - 1 ), ]; } } diff --git a/includes/class-CategoryYearMonthDay.php b/includes/class-CategoryYearMonthDay.php index de1e260..b518d89 100644 --- a/includes/class-CategoryYearMonthDay.php +++ b/includes/class-CategoryYearMonthDay.php @@ -1,85 +1,56 @@ . namespace itwikidelbot; /** - * Handle a daily category + * Handle a daily category that contains semplified PDC pages * * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_del_19_febbraio_2018 */ -class CategoryYearMonthDay extends CategoryYearMonth { +class CategoryYearMonthDay extends PageYearMonthDay { /** * Template name * * @override CategoryTemplated::TEMPLATE_NAME */ const TEMPLATE_NAME = 'CATEGORY_DAY'; - /** - * Day - * - * @var int 1-31 - */ - private $day; - - /** - * Constructor - * - * @param $year int - * @param $month int 1-12 - * @param $day int 1-31 - * @see CategoryYearMonth::__construct() - */ - public function __construct( $year, $month, $day ) { - $this->day = $day; - parent::__construct( $year, $month ); - } - - /** - * Get the day - * - * @return int 1-13 - */ - public function getDay() { - return $this->day; - } - - /** * Template arguments * * @override CategoryTemplated::getTemplateArguments() */ public function getTemplateArguments() { return [ - ( new parent( $this->getYear(), $this->getMonth() ) ) + ( new CategoryYearMonth( $this->getYear(), $this->getMonth() ) ) ->getTemplatedTitle(), $this->getYear(), $this->getMonth(), Months::number2name( $this->getMonth() - 1 ), $this->getDay(), ]; } + } diff --git a/includes/class-CategoryYear.php b/includes/class-PageYear.php similarity index 55% copy from includes/class-CategoryYear.php copy to includes/class-PageYear.php index 42d7f18..af40aa5 100644 --- a/includes/class-CategoryYear.php +++ b/includes/class-PageYear.php @@ -1,75 +1,51 @@ . namespace itwikidelbot; /** - * Handle a yearly category - * - * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_-_2017 + * Abstraction of a page related to a year */ -class CategoryYear extends PageTemplated { - - /** - * Template name of this category - * - * @override CategoryTemplated::TEMPLATE_NAME - */ - const TEMPLATE_NAME = 'CATEGORY_YEAR'; +abstract class PageYear extends PageTemplated { /** * Year * * @var int */ private $year; /** * Constructor * * @param $year int - * @see CategoryTemplated::__construct() + * @see PageTemplated::__construct() */ public function __construct( $year ) { $this->year = $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-CategoryYearMonth.php b/includes/class-PageYearMonth.php similarity index 52% copy from includes/class-CategoryYearMonth.php copy to includes/class-PageYearMonth.php index f55989b..d7cc889 100644 --- a/includes/class-CategoryYearMonth.php +++ b/includes/class-PageYearMonth.php @@ -1,82 +1,52 @@ . namespace itwikidelbot; /** - * Handle a monthly category - * - * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_-_aprile_2018 + * Abstraction of a page related to a month (in a certain year) */ -class CategoryYearMonth extends CategoryYear { - - /** - * Template name of this category - * - * @override CategoryTemplated::TEMPLATE_NAME - */ - const TEMPLATE_NAME = 'CATEGORY_MONTH'; +abstract class PageYearMonth extends PageYear { /** * Month * * @var int 1-12 */ private $month; /** * Constructor * * @param $year int * @param $month int 1-12 - * @see CategoryYear::__construct() + * @see PageYear::__construct() */ public function __construct( $year, $month ) { $this->month = $month; parent::__construct( $year ); } /** * Get the month * * @return int 1-12 */ public function getMonth() { return $this->month; } - /** - * Template arguments - * - * @override CategoryTemplated::getTemplateArguments() - */ - public function getTemplateArguments() { - return [ - ( new parent( $this->getYear() ) ) - ->getTemplatedTitle(), - $this->getYear(), - $this->getMonth(), - Months::number2name( $this->getMonth() - 1 ), - ]; - } } diff --git a/includes/class-CategoryYearMonthDay.php b/includes/class-PageYearMonthDay.php similarity index 51% copy from includes/class-CategoryYearMonthDay.php copy to includes/class-PageYearMonthDay.php index de1e260..738e1ae 100644 --- a/includes/class-CategoryYearMonthDay.php +++ b/includes/class-PageYearMonthDay.php @@ -1,85 +1,53 @@ . namespace itwikidelbot; /** - * Handle a daily category - * - * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_del_19_febbraio_2018 + * Abstraction of a page related to a day (in a certain month of a certain year) */ -class CategoryYearMonthDay extends CategoryYearMonth { - - /** - * Template name - * - * @override CategoryTemplated::TEMPLATE_NAME - */ - const TEMPLATE_NAME = 'CATEGORY_DAY'; +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 CategoryYearMonth::__construct() + * @see PageYearMonth::__construct() */ public function __construct( $year, $month, $day ) { - $this->day = $day; + $this->day = $day; parent::__construct( $year, $month ); } /** * Get the day * * @return int 1-13 */ public function getDay() { return $this->day; } - - /** - * Template arguments - * - * @override CategoryTemplated::getTemplateArguments() - */ - public function getTemplateArguments() { - return [ - ( new parent( $this->getYear(), $this->getMonth() ) ) - ->getTemplatedTitle(), - $this->getYear(), - $this->getMonth(), - Months::number2name( $this->getMonth() - 1 ), - $this->getDay(), - ]; - } }