Documentation

BookRepositoryImpl
in package
implements BookRepository

Class BookRepositoryImpl

Implements the BookRepository interface using a PDO connection.

Table of Contents

Interfaces

BookRepository
Interface BookRepository

Properties

$connection  : PDO
$sectionRepository  : SectionRepository
$table  : string

Methods

__construct()  : mixed
Constructor for the BookRepositoryImpl class.
createBook()  : bool
Creates a new book.
deleteBook()  : bool
Deletes a book by its ID.
getAllBooks()  : array<string|int, mixed>
Retrieves all books.
getBookById()  : Book|null
Retrieves a book by its ID.
updateBook()  : bool
Updates an existing book.
assemblerBookWithSectionAndIsbn()  : Book
Assembles a Book entity with its section and ISBN.

Properties

Methods

__construct()

Constructor for the BookRepositoryImpl class.

public __construct() : mixed

Initializes the database connection and section repository.

createBook()

Creates a new book.

public createBook(Book $book) : bool
Parameters
$book : Book

The book to be created.

Return values
bool

Returns true if the book was successfully created, false otherwise.

deleteBook()

Deletes a book by its ID.

public deleteBook(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.

getAllBooks()

Retrieves all books.

public getAllBooks() : 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|null
Parameters
$idBook : int

The ID of the book to retrieve.

Return values
Book|null

Returns the book if found, null otherwise.

updateBook()

Updates an existing book.

public updateBook(Book $book) : bool
Parameters
$book : Book

The book to be updated.

Return values
bool

Returns true if the book was successfully updated, false otherwise.

assemblerBookWithSectionAndIsbn()

Assembles a Book entity with its section and ISBN.

private assemblerBookWithSectionAndIsbn(object $dataBook) : Book
Parameters
$dataBook : object

The database result.

Return values
Book

The assembled Book entity.


        
On this page

Search results