diff --git a/favourites/classes/local/repository/favourite_repository.php b/favourites/classes/local/repository/favourite_repository.php index 3b8e012ccca..2b94f91caec 100644 --- a/favourites/classes/local/repository/favourite_repository.php +++ b/favourites/classes/local/repository/favourite_repository.php @@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die(); * @copyright 2018 Jake Dallimore * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class favourite_repository implements ifavourite_repository { +class favourite_repository implements favourite_repository_interface { /** * @var string the name of the table which favourites are stored in. diff --git a/favourites/classes/local/repository/crud_repository.php b/favourites/classes/local/repository/favourite_repository_interface.php similarity index 80% rename from favourites/classes/local/repository/crud_repository.php rename to favourites/classes/local/repository/favourite_repository_interface.php index 06033f5b3cc..138872a974a 100644 --- a/favourites/classes/local/repository/crud_repository.php +++ b/favourites/classes/local/repository/favourite_repository_interface.php @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . /** - * Contains the crud_repository interface. + * Contains the favourite_repository interface. * * @package core_favourites * @copyright 2018 Jake Dallimore @@ -26,9 +26,9 @@ use \core_favourites\local\entity\favourite; defined('MOODLE_INTERNAL') || die(); /** - * The crud_repository interface, defining the basic CRUD operations for any repository types within core_favourites. + * The favourite_repository interface, defining the basic CRUD operations for favourite type items within core_favourites. */ -interface crud_repository { +interface favourite_repository_interface { /** * Add one item to this repository. * @@ -102,4 +102,16 @@ interface crud_repository { * @return void */ public function delete(int $id); + + /** + * Find a single favourite, based on it's unique identifiers. + * + * @param int $userid the id of the user to which the favourite belongs. + * @param string $component the frankenstyle component name. + * @param string $itemtype the type of the favourited item. + * @param int $itemid the id of the item which was favourited (not the favourite's id). + * @param int $contextid the contextid of the item which was favourited. + * @return favourite the favourite. + */ + public function find_favourite(int $userid, string $component, string $itemtype, int $itemid, int $contextid) : favourite; } diff --git a/favourites/classes/local/repository/ifavourite_repository.php b/favourites/classes/local/repository/ifavourite_repository.php deleted file mode 100644 index bbabf6625db..00000000000 --- a/favourites/classes/local/repository/ifavourite_repository.php +++ /dev/null @@ -1,46 +0,0 @@ -. -/** - * Contains the favourite_repository interface. - * - * @package core_favourites - * @copyright 2018 Jake Dallimore - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -namespace core_favourites\local\repository; -use \core_favourites\local\entity\favourite; - -defined('MOODLE_INTERNAL') || die(); - -/** - * The favourite_repository interface, defining additional operations useful to favourite type repositories. - * - * @copyright 2018 Jake Dallimore - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -interface ifavourite_repository extends crud_repository { - /** - * Find a single favourite, based on it's unique identifiers. - * - * @param int $userid the id of the user to which the favourite belongs. - * @param string $component the frankenstyle component name. - * @param string $itemtype the type of the favourited item. - * @param int $itemid the id of the item which was favourited (not the favourite's id). - * @param int $contextid the contextid of the item which was favourited. - * @return favourite the favourite. - */ - public function find_favourite(int $userid, string $component, string $itemtype, int $itemid, int $contextid) : favourite; -} diff --git a/favourites/classes/local/service/user_favourite_service.php b/favourites/classes/local/service/user_favourite_service.php index 9364a94dd1e..15dc06b3f24 100644 --- a/favourites/classes/local/service/user_favourite_service.php +++ b/favourites/classes/local/service/user_favourite_service.php @@ -23,6 +23,7 @@ */ namespace core_favourites\local\service; use \core_favourites\local\entity\favourite; +use \core_favourites\local\repository\favourite_repository_interface; defined('MOODLE_INTERNAL') || die(); @@ -32,14 +33,14 @@ defined('MOODLE_INTERNAL') || die(); * This class is responsible for exposing key operations (add, remove, find) and enforces any business logic necessary to validate * authorization/data integrity for these operations. * - * All object persistence is delegated to the ifavourite_repository. + * All object persistence is delegated to the favourite_repository_interface object. * * @copyright 2018 Jake Dallimore * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_favourite_service { - /** @var ifavourite_repository $repo the user favourites repository object. */ + /** @var favourite_repository_interface $repo the favourite repository object. */ protected $repo; /** @var int $userid the id of the user to which this favourites service is scoped. */ @@ -49,9 +50,9 @@ class user_favourite_service { * The user_favourite_service constructor. * * @param \context_user $usercontext The context of the user to which this service operations are scoped. - * @param \core_favourites\local\repository\ifavourite_repository $repository a user favourites repository. + * @param \core_favourites\local\repository\favourite_repository_interface $repository a favourites repository. */ - public function __construct(\context_user $usercontext, \core_favourites\local\repository\ifavourite_repository $repository) { + public function __construct(\context_user $usercontext, favourite_repository_interface $repository) { $this->repo = $repository; $this->userid = $usercontext->instanceid; } diff --git a/favourites/tests/service_test.php b/favourites/tests/service_test.php index 277b8482b92..6600c2dccc6 100644 --- a/favourites/tests/service_test.php +++ b/favourites/tests/service_test.php @@ -58,7 +58,7 @@ class user_favourite_service_testcase extends advanced_testcase { */ protected function get_mock_repository(array $mockstore) { // This mock will just store data in an array. - $mockrepo = $this->getMockBuilder(\core_favourites\local\repository\ifavourite_repository::class) + $mockrepo = $this->getMockBuilder(\core_favourites\local\repository\favourite_repository_interface::class) ->setMethods([]) ->getMock(); $mockrepo->expects($this->any())