Documentation

Jsonq
in package
uses JsonQueriable

Table of Contents

Properties

$_baseContents  : array<string|int, mixed>
Stores base contents.
$_conditions  : array<string|int, mixed>
Stores all conditions.
$_except  : array<string|int, mixed>
contains column names for except
$_isProcessed  : bool
$_map  : mixed
contain prepared data for process
$_node  : string|array<string|int, mixed>
store node path
$_rulesMap  : array<string|int, mixed>
map all conditions with methods
$_select  : array<string|int, mixed>
contains column names

Methods

__construct()  : mixed
this constructor set main json file path otherwise create it and read file contents and decode as an array and store it in $this->_data
at()  : $this
Alias of from() method
avg()  : string
getting average value from prepared data
chunk()  : object|array<string|int, mixed>|bool
getting chunk values from prepared data
collect()  : jsonq
import parsed data from raw json
column()  : object|array<string|int, mixed>
getting specific key's value from prepared data
copy()  : Jsonq
Deep copy current instance
count()  : int
count prepared data
countGroupBy()  : mixed
each()  : mixed
take action of each element of prepared data
except()  : $this
select desired column for except
exists()  : bool
check data exists in system
fetch()  : array<string|int, mixed>|object
alias of get method
filter()  : mixed|array<string|int, mixed>
filtered each element of prepared data
find()  : mixed
getting data from desire path
first()  : object|array<string|int, mixed>|null
getting first element of prepared data
from()  : $this
Set node path, where JsonQ start to prepare
get()  : array<string|int, mixed>|object
getting prepared data
groupBy()  : $this
getting group data from specific column
implode()  : string|array<string|int, mixed>
implode resulting data from desire key and delimeter
import()  : bool
import data from file
isJson()  : bool|array<string|int, mixed>
Check given value is valid JSON
json()  : jsonq
import raw JSON data for process
keys()  : object|array<string|int, mixed>
getting all keys from prepared data
last()  : object|array<string|int, mixed>|null
getting last element of prepared data
macro()  : bool
make macro for custom where clause
max()  : int
getting max value from prepared data
min()  : string
getting min value from prepared data
nth()  : object|array<string|int, mixed>|null
getting nth number of element of prepared data
orWhere()  : $this
make WHERE clause with OR
pipe()  : object|array<string|int, mixed>
pipe send output in next pipe
reProcess()  : $this
Our system will cache processed data and prevend multiple time processing. If you want to reprocess this method can help you
reset()  : jsonq
reset given data to the $_map
select()  : $this
select desired column
size()  : int
size is an alias of count
sort()  : Jsonq
Sort an array value
sortBy()  : object|array<string|int, mixed>|null
sorting from prepared data
sortByCallable()  : object|array<string|int, mixed>|null
Sort prepared data using a custom sort function.
sum()  : int
sum prepared data
takeColumn()  : mixed
then()  : jsonq
then method set position of working data
toJson()  : string
getting raw JSON from prepared data
transform()  : object|array<string|int, mixed>
transform prepared data by using callable function
values()  : object|array<string|int, mixed>
getting all values from prepared data
where()  : $this
make WHERE clause
whereBool()  : $this
make WHERE Boolean clause
whereContains()  : $this
make WHERE CONTAINS clause
whereDate()  : $this
make WHERE DATE clause
whereEndsWith()  : $this
make WHERE ENDS WITH clause
whereIn()  : $this
make WHERE IN clause
whereMatch()  : $this
make WHERE MATCH clause
whereMonth()  : $this
make WHERE month clause
whereNotIn()  : $this
make WHERE NOT IN clause
whereNotNull()  : $this
make WHERE NOT NULL clause
whereNull()  : $this
make WHERE NULL clause
whereStartsWith()  : $this
make WHERE START WITH clause
whereYear()  : $this
make WHERE Year clause
exceptColumn()  : array<string|int, mixed>
selecting specific column
getData()  : mixed
get data from node path
getDataFromFile()  : bool|string|array<string|int, mixed>
Read JSON data from file
getFromNested()  : bool|array<string|int, mixed>|mixed
Get data from nested array
isMultiArray()  : bool
Check given value is multidimensional array
makeImplode()  : string|null
process implode from resulting data
makeWhere()  : $this
generator for AND and OR where
objectToArray()  : array<string|int, mixed>|mixed
Parse object to array
prepare()  : $this
Prepare data from desire conditions
prepareResult()  : array<string|int, mixed>|mixed
Prepare data for result
processConditions()  : array<string|int, mixed>|string|object
process AND and OR conditions
selectColumn()  : array<string|int, mixed>
selecting specific column

Properties

$_baseContents

Stores base contents.

protected array<string|int, mixed> $_baseContents = []

$_conditions

Stores all conditions.

protected array<string|int, mixed> $_conditions = []

$_except

contains column names for except

protected array<string|int, mixed> $_except = []

$_map

contain prepared data for process

protected mixed $_map

$_node

store node path

protected string|array<string|int, mixed> $_node = ''

$_rulesMap

map all conditions with methods

protected static array<string|int, mixed> $_rulesMap = ['=' => 'equal', 'eq' => 'equal', '==' => 'strictEqual', 'seq' => 'strictEqual', '!=' => 'notEqual', 'neq' => 'notEqual', '!==' => 'strictNotEqual', 'sneq' => 'strictNotEqual', '>' => 'greaterThan', 'gt' => 'greaterThan', '<' => 'lessThan', 'lt' => 'lessThan', '>=' => 'greaterThanOrEqual', 'gte' => 'greaterThanOrEqual', '<=' => 'lessThanOrEqual', 'lte' => 'lessThanOrEqual', 'in' => 'in', 'notin' => 'notIn', 'null' => 'isNull', 'notnull' => 'isNotNull', 'startswith' => 'startWith', 'endswith' => 'endWith', 'match' => 'match', 'contains' => 'contains', 'dates' => 'dateEqual', 'month' => 'monthEqual', 'year' => 'yearEqual']

$_select

contains column names

protected array<string|int, mixed> $_select = []

Methods

__construct()

this constructor set main json file path otherwise create it and read file contents and decode as an array and store it in $this->_data

public __construct([null $jsonFile = null ]) : mixed
Parameters
$jsonFile : null = null
Tags
throws
FileNotFoundException
throws
InvalidJsonException

at()

Alias of from() method

public at([null $node = null ]) : $this
Parameters
$node : null = null
Tags
throws
NullValueException
Return values
$this

avg()

getting average value from prepared data

public avg([int $column = null ]) : string
Parameters
$column : int = null
Tags
throws
ConditionNotAllowedException
Return values
string

chunk()

getting chunk values from prepared data

public chunk(int $amount[, mixed $fn = null ]) : object|array<string|int, mixed>|bool
Parameters
$amount : int
$fn : mixed = null
Tags
throws
ConditionNotAllowedException
Return values
object|array<string|int, mixed>|bool

collect()

import parsed data from raw json

public collect(array<string|int, mixed>|object $data) : jsonq
Parameters
$data : array<string|int, mixed>|object
Return values
jsonq

column()

getting specific key's value from prepared data

public column(string $column) : object|array<string|int, mixed>
Parameters
$column : string
Tags
throws
ConditionNotAllowedException
Return values
object|array<string|int, mixed>

countGroupBy()

public countGroupBy(mixed $column) : mixed
Parameters
$column : mixed

except()

select desired column for except

public except() : $this
Return values
$this

fetch()

alias of get method

public fetch([bool $object = true ]) : array<string|int, mixed>|object
Parameters
$object : bool = true
Tags
throws
ConditionNotAllowedException
Return values
array<string|int, mixed>|object

filter()

filtered each element of prepared data

public filter(callable $fn[, bool $key = false ]) : mixed|array<string|int, mixed>
Parameters
$fn : callable
$key : bool = false
Tags
throws
ConditionNotAllowedException
Return values
mixed|array<string|int, mixed>

first()

getting first element of prepared data

public first([bool $object = false ]) : object|array<string|int, mixed>|null
Parameters
$object : bool = false
Tags
throws
ConditionNotAllowedException
Return values
object|array<string|int, mixed>|null

from()

Set node path, where JsonQ start to prepare

public from([null $node = null ]) : $this
Parameters
$node : null = null
Tags
throws
NullValueException
Return values
$this

get()

getting prepared data

public get([bool $object = false ]) : array<string|int, mixed>|object
Parameters
$object : bool = false
Tags
throws
ConditionNotAllowedException
Return values
array<string|int, mixed>|object

groupBy()

getting group data from specific column

public groupBy(string $column) : $this
Parameters
$column : string
Tags
throws
ConditionNotAllowedException
Return values
$this

implode()

implode resulting data from desire key and delimeter

public implode(string|array<string|int, mixed> $key[, string $delimiter = ',' ]) : string|array<string|int, mixed>
Parameters
$key : string|array<string|int, mixed>
$delimiter : string = ','
Tags
throws
ConditionNotAllowedException
Return values
string|array<string|int, mixed>

isJson()

Check given value is valid JSON

public isJson(string $value[, bool $isReturnMap = false ]) : bool|array<string|int, mixed>
Parameters
$value : string
$isReturnMap : bool = false
Return values
bool|array<string|int, mixed>

json()

import raw JSON data for process

public json(string $data) : jsonq
Parameters
$data : string
Return values
jsonq

keys()

getting all keys from prepared data

public keys() : object|array<string|int, mixed>
Tags
throws
ConditionNotAllowedException
Return values
object|array<string|int, mixed>

last()

getting last element of prepared data

public last([bool $object = false ]) : object|array<string|int, mixed>|null
Parameters
$object : bool = false
Tags
throws
ConditionNotAllowedException
Return values
object|array<string|int, mixed>|null

macro()

make macro for custom where clause

public static macro(string $name, callable $fn) : bool
Parameters
$name : string
$fn : callable
Return values
bool

max()

getting max value from prepared data

public max([int $column = null ]) : int
Parameters
$column : int = null
Tags
throws
ConditionNotAllowedException
Return values
int

min()

getting min value from prepared data

public min([int $column = null ]) : string
Parameters
$column : int = null
Tags
throws
ConditionNotAllowedException
Return values
string

nth()

getting nth number of element of prepared data

public nth(int $index[, bool $object = false ]) : object|array<string|int, mixed>|null
Parameters
$index : int
$object : bool = false
Tags
throws
ConditionNotAllowedException
Return values
object|array<string|int, mixed>|null

orWhere()

make WHERE clause with OR

public orWhere([string $key = null ][, string $condition = null ][, mixed $value = null ]) : $this
Parameters
$key : string = null
$condition : string = null
$value : mixed = null
Return values
$this

pipe()

pipe send output in next pipe

public pipe(callable $fn[, string|null $class = null ]) : object|array<string|int, mixed>
Parameters
$fn : callable
$class : string|null = null
Tags
throws
ConditionNotAllowedException
Return values
object|array<string|int, mixed>

reProcess()

Our system will cache processed data and prevend multiple time processing. If you want to reprocess this method can help you

public reProcess() : $this
Return values
$this

reset()

reset given data to the $_map

public reset([mixed $data = null ][, bool $instance = false ]) : jsonq
Parameters
$data : mixed = null
$instance : bool = false
Return values
jsonq

select()

select desired column

public select() : $this
Return values
$this

sort()

Sort an array value

public sort([string $order = 'asc' ]) : Jsonq
Parameters
$order : string = 'asc'
Return values
Jsonq

sortBy()

sorting from prepared data

public sortBy(string $column[, string $order = 'asc' ]) : object|array<string|int, mixed>|null
Parameters
$column : string
$order : string = 'asc'
Tags
throws
ConditionNotAllowedException
Return values
object|array<string|int, mixed>|null

sortByCallable()

Sort prepared data using a custom sort function.

public sortByCallable(callable $sortFunc) : object|array<string|int, mixed>|null
Parameters
$sortFunc : callable
Tags
throws
ConditionNotAllowedException
Return values
object|array<string|int, mixed>|null

takeColumn()

public takeColumn(mixed $array) : mixed
Parameters
$array : mixed

transform()

transform prepared data by using callable function

public transform(callable $fn) : object|array<string|int, mixed>
Parameters
$fn : callable
Tags
throws
ConditionNotAllowedException
Return values
object|array<string|int, mixed>

values()

getting all values from prepared data

public values() : object|array<string|int, mixed>
Tags
throws
ConditionNotAllowedException
Return values
object|array<string|int, mixed>

where()

make WHERE clause

public where(string $key[, string $condition = null ][, mixed $value = null ]) : $this
Parameters
$key : string
$condition : string = null
$value : mixed = null
Return values
$this

whereBool()

make WHERE Boolean clause

public whereBool(string $key, mixed $value) : $this
Parameters
$key : string
$value : mixed
Return values
$this

whereContains()

make WHERE CONTAINS clause

public whereContains(string $key, string $value) : $this
Parameters
$key : string
$value : string
Return values
$this

whereDate()

make WHERE DATE clause

public whereDate(string $key, string $value) : $this
Parameters
$key : string
$value : string
Return values
$this

whereEndsWith()

make WHERE ENDS WITH clause

public whereEndsWith(string $key, string $value) : $this
Parameters
$key : string
$value : string
Return values
$this

whereIn()

make WHERE IN clause

public whereIn([string $key = null ][, array<string|int, mixed> $value = [] ]) : $this
Parameters
$key : string = null
$value : array<string|int, mixed> = []
Return values
$this

whereMatch()

make WHERE MATCH clause

public whereMatch(string $key, string $value) : $this
Parameters
$key : string
$value : string
Return values
$this

whereMonth()

make WHERE month clause

public whereMonth(string $key, string $value) : $this
Parameters
$key : string
$value : string
Return values
$this

whereNotIn()

make WHERE NOT IN clause

public whereNotIn([string $key = null ][, mixed $value = [] ]) : $this
Parameters
$key : string = null
$value : mixed = []
Return values
$this

whereNotNull()

make WHERE NOT NULL clause

public whereNotNull([string $key = null ]) : $this
Parameters
$key : string = null
Return values
$this

whereNull()

make WHERE NULL clause

public whereNull([string $key = null ]) : $this
Parameters
$key : string = null
Return values
$this

whereStartsWith()

make WHERE START WITH clause

public whereStartsWith(string $key, string $value) : $this
Parameters
$key : string
$value : string
Return values
$this

whereYear()

make WHERE Year clause

public whereYear(string $key, string $value) : $this
Parameters
$key : string
$value : string
Return values
$this

exceptColumn()

selecting specific column

protected exceptColumn(mixed $array) : array<string|int, mixed>
Parameters
$array : mixed
Return values
array<string|int, mixed>

getData()

get data from node path

protected getData() : mixed

getDataFromFile()

Read JSON data from file

protected getDataFromFile(string $file[, string $type = 'application/json' ]) : bool|string|array<string|int, mixed>
Parameters
$file : string
$type : string = 'application/json'
Tags
throws
FileNotFoundException
throws
InvalidJsonException
Return values
bool|string|array<string|int, mixed>

getFromNested()

Get data from nested array

protected getFromNested(mixed $map, mixed $node) : bool|array<string|int, mixed>|mixed
Parameters
$map : mixed

array

$node : mixed

string

Return values
bool|array<string|int, mixed>|mixed

isMultiArray()

Check given value is multidimensional array

protected isMultiArray(array<string|int, mixed> $arr) : bool
Parameters
$arr : array<string|int, mixed>
Return values
bool

makeImplode()

process implode from resulting data

protected makeImplode(string $key, string $delimiter) : string|null
Parameters
$key : string
$delimiter : string
Return values
string|null

makeWhere()

generator for AND and OR where

protected makeWhere(string $key[, string $condition = null ][, mixed $value = null ]) : $this
Parameters
$key : string
$condition : string = null
$value : mixed = null
Return values
$this

objectToArray()

Parse object to array

protected objectToArray(object $obj) : array<string|int, mixed>|mixed
Parameters
$obj : object
Return values
array<string|int, mixed>|mixed

prepareResult()

Prepare data for result

protected prepareResult(mixed $data, bool $isObject) : array<string|int, mixed>|mixed
Parameters
$data : mixed
$isObject : bool
Return values
array<string|int, mixed>|mixed

processConditions()

process AND and OR conditions

protected processConditions() : array<string|int, mixed>|string|object
Tags
throws
ConditionNotAllowedException
Return values
array<string|int, mixed>|string|object

selectColumn()

selecting specific column

protected selectColumn(mixed $array) : array<string|int, mixed>
Parameters
$array : mixed
Return values
array<string|int, mixed>

        
On this page

Search results