Documentation

Database
in package

Table of Contents

Constants

DB_FILE  = __DIR__ . "/database.json"

Properties

$data  : array<string|int, mixed>

Methods

__construct()  : mixed
createRecipe()  : Recipe
create recipe, push to data field and return
getRecipeById()  : Recipe
getRecipesByTag()  : mixed
filter recipes by tag
paginateData()  : array<string|int, mixed>
return $count values with offset of $offset from $data
updateRecipe()  : Recipe
update recipe, update it in data field and return updated
uuidv4()  : string
generate uuid-v4
createDatabaseFileIfAbsent()  : void
putData()  : void
reset database.json with data field value
readData()  : void
decode database.json and set data field

Constants

DB_FILE

private mixed DB_FILE = __DIR__ . "/database.json"

Properties

$data

public array<string|int, mixed> $data

Methods

__construct()

public __construct() : mixed

createRecipe()

create recipe, push to data field and return

public createRecipe(array<string|int, mixed> $data) : Recipe
Parameters
$data : array<string|int, mixed>
Return values
Recipe

getRecipeById()

public getRecipeById(string $id) : Recipe
Parameters
$id : string
Tags
throws
Exception

if recipe not found

Return values
Recipe

getRecipesByTag()

filter recipes by tag

public getRecipesByTag(string $tag) : mixed
Parameters
$tag : string

paginateData()

return $count values with offset of $offset from $data

public paginateData(array<string|int, mixed> $data, int $offset[, int|null $count = null ]) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>
$offset : int
$count : int|null = null

if null return all values

Return values
array<string|int, mixed>

updateRecipe()

update recipe, update it in data field and return updated

public updateRecipe(string $id, array<string|int, mixed> $data) : Recipe
Parameters
$id : string
$data : array<string|int, mixed>
Return values
Recipe

uuidv4()

generate uuid-v4

public static uuidv4() : string
Return values
string

createDatabaseFileIfAbsent()

private createDatabaseFileIfAbsent() : void

putData()

reset database.json with data field value

private putData() : void

readData()

decode database.json and set data field

private readData() : void

        
On this page

Search results