From fb3b6555b2a05e8325e6722a896b6f2553b90043 Mon Sep 17 00:00:00 2001 From: Mathieu Ducrot Date: Thu, 19 Sep 2024 11:01:39 +0200 Subject: [PATCH] Rename MonthelableTrait as MonthYearTrait and add interfaces --- CHANGELOG_add_trait_monthelable_and_created.md | 4 ++-- src/Entity/CreatableInterface.php | 11 +++++++++++ src/Entity/CreatableTrait.php | 2 +- src/Entity/MonthYearInterface.php | 18 ++++++++++++++++++ ...MonthelableTrait.php => MonthYearTrait.php} | 4 ++-- 5 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 src/Entity/CreatableInterface.php create mode 100644 src/Entity/MonthYearInterface.php rename src/Entity/{MonthelableTrait.php => MonthYearTrait.php} (93%) diff --git a/CHANGELOG_add_trait_monthelable_and_created.md b/CHANGELOG_add_trait_monthelable_and_created.md index a8f2df5..3f3824a 100644 --- a/CHANGELOG_add_trait_monthelable_and_created.md +++ b/CHANGELOG_add_trait_monthelable_and_created.md @@ -1,3 +1,3 @@ ### Added -`Entity::CreatableTrait` Trait with creation date -`Entity::MonthelableTrait` Trait with numeric representation of a month and his numeric year. Useful for statistics purposes. \ No newline at end of file +`Entity::CreatableTrait` Trait & interface with creation date +`Entity::MonthYearTrait` Trait & interface with numeric representation of a month and his numeric year. Useful for statistics purposes. diff --git a/src/Entity/CreatableInterface.php b/src/Entity/CreatableInterface.php new file mode 100644 index 0000000..45760d6 --- /dev/null +++ b/src/Entity/CreatableInterface.php @@ -0,0 +1,11 @@ +year = $year; } - public function setMonthelableDate(\DateTime $date): void + public function setMonthYearFromDate(\DateTime $date): void { $this->month = (int) $date->format('n'); $this->year = (int) $date->format('Y');