BookService
in package
Class BookService
Provides services for managing books.
Table of Contents
Properties
Methods
- __construct() : mixed
- Constructor for the BookService class.
- create() : bool
- Creates a new book.
- delete() : bool
- Deletes a book by its ID.
- getAll() : array<string|int, mixed>
- Retrieves all books.
- getBookById() : Book
- Retrieves a book by its ID.
- update() : bool
- Updates an existing book.
- assemblerBookEntitie() : Book
- Assembles a Book entity from provided data.
Properties
$bookRepository
private
BookRepository
$bookRepository
$sectionService
private
SectionService
$sectionService
Methods
__construct()
Constructor for the BookService class.
public
__construct(BookRepository $bookRepository) : mixed
Initializes the book repository and section service.
Parameters
- $bookRepository : BookRepository
-
The repository for managing books.
create()
Creates a new book.
public
create(object $data) : bool
Parameters
- $data : object
-
The data for creating the book.
Return values
bool —Returns true if the book was successfully created, false otherwise.
delete()
Deletes a book by its ID.
public
delete(int $idBook) : bool
Parameters
- $idBook : int
-
The ID of the book to delete.
Return values
bool —Returns true if the book was successfully deleted, false otherwise.
getAll()
Retrieves all books.
public
getAll() : array<string|int, mixed>
Return values
array<string|int, mixed> —Returns an array of all books.
getBookById()
Retrieves a book by its ID.
public
getBookById(int $idBook) : Book
Parameters
- $idBook : int
-
The ID of the book to retrieve.
Return values
Book —Returns the book if found.
update()
Updates an existing book.
public
update(int $idBook, object $data) : bool
Parameters
- $idBook : int
-
The ID of the book to be updated.
- $data : object
-
The data for updating the book.
Return values
bool —Returns true if the book was successfully updated, false otherwise.
assemblerBookEntitie()
Assembles a Book entity from provided data.
private
assemblerBookEntitie(object $data) : Book
Parameters
- $data : object
-
The data for the book.
Return values
Book —The assembled Book entity.