Complete the code to declare the Repository interface.
<?php
interface [1] {
public function findAll();
}
The interface is named Repository to define the contract for data access.
Complete the method signature to find an item by its ID.
<?php
interface Repository {
public function findById([1] $id);
}
The findById method usually takes an int as the ID parameter.
Fix the error in the repository implementation class declaration.
<?php class UserRepository [1] Repository { public function findAll() { // code to get all users } }
In PHP, classes implement interfaces using the implements keyword.
Fill both blanks to complete the method that saves a user entity.
<?php class UserRepository implements Repository { public function save([1] $user) : [2] { // code to save user } }
The save method takes a User object and returns a bool indicating success.
Fill all three blanks to complete the repository method that deletes a user by ID.
<?php class UserRepository implements Repository { public function delete([1] $id) : [2] { // code to delete user return [3]; } }
The delete method takes an int ID, returns a bool, and returns true on success.
