\BookManager

Handles book statistics.

Summary

Methods
Properties
Constants
__construct()
getStats()
getTypes()
getCategories()
getBookData()
getBookCount()
getBookContent()
hasCover()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
filterBookData()
sortBookData()
$jsonReader
N/A

Properties

$jsonReader

$jsonReader : \JsonReader

JsonReader object to deal with json files.

Type

\JsonReader

Methods

__construct()

__construct() : mixed

Initializes the json reader object.

Returns

mixed

getStats()

getStats() : array

Returns the statistical information (how many books read so far, etc.).

Returns

array —

The statistical information.

getTypes()

getTypes() : array

Returns all types which are currently in use.

Returns

array —

All types which are currently in use.

getCategories()

getCategories() : array

Returns all categories which are currently in use.

Returns

array —

All categories which are currently in use.

getBookData()

getBookData(array  $filters = array()) : array

Returns available book note data.

Parameters

array $filters

Filters to filter the data (e.g. display only ebooks).

Returns

array —

The available book note data.

getBookCount()

getBookCount() : int

Returns the number of book note files.

Returns

int —

The number of book note files.

getBookContent()

getBookContent(int  $id) : array

Returns the content of a given book note.

Parameters

int $id

The id of the book note for which the content should be returned.

Returns

array —

The title and the content of that book note.

hasCover()

hasCover(string  $filename) : bool

Checks whether a given book note file has a cover.

Parameters

string $filename

The name of the book note file.

Returns

bool —

True if a cover exists, else false.

filterBookData()

filterBookData(array  $data, array  $filters) : array

Filters the data if filters are set (e.g. display only eBooks or only a specific category).

Parameters

array $data

The data to be filtered.

array $filters

Filters to be applied to the data (e.g. {'types': ['ebook']} to display only ebooks).

Returns

array —

The filtered data.

sortBookData()

sortBookData(array  $data, string  $sortType) : array

Sorts the data by a given metric.

Parameters

array $data

The data to be sorted.

string $sortType

The metric for sorting. Can be 'newest', 'alphabetical' or 'mostread'.

Returns

array —

The sorted data.