Arikaim CMS

FeedCollection extends Collection
in package
implements CollectionInterface, FeedsInterface, Countable, ArrayAccess, IteratorAggregate

Feed Collection class

Table of Contents

Interfaces

CollectionInterface
Collection interface
FeedsInterface
Feeds Collection interface
Countable
ArrayAccess
IteratorAggregate

Constants

DEFAULT_ITEMS_PER_PAGE  = 25

Properties

$baseUrl  : string
Feed base url
$data  : array<string|int, mixed>
Collection items data
$itemsKey  : string|null
Feed items key
$keyMaps  : array<string|int, mixed>
Item key mappings
$pageKey  : string
Array key in params
$params  : array<string|int, mixed>|string
Url params
$perPageKey  : string|null
Items per page array key

Methods

__construct()  : mixed
Constructor
__get()  : mixed
Get value
__set()  : mixed
Set value
add()  : void
Add item to collection
addField()  : bool
Add value
applyKeyMaps()  : array<string|int, mixed>
Change item array keys
baseUrl()  : FeedCollection
Set feed base url
clear()  : void
Clear collection data
copy()  : self
Clone object
count()  : int
Return collection items count.
create()  : Collection
Create colleciton
createFromFile()  : Collection
Create colection form json file
fetch()  : FeedCollection
Fetch feed
findItem()  : array<string|int, mixed>|null
Find feed item
get()  : mixed
Get value from collection
getArray()  : array<string|int, mixed>
Return array values
getBaseUrl()  : string
Get base url
getBool()  : bool
Get boolean value
getByPath()  : mixed
Get value by path
getCollection()  : Collection
Get collection item
getFloat()  : float|null
Get float value
getInt()  : int|null
Get int value
getItem()  : mixed
Get feed item
getItems()  : array<string|int, mixed>
Return feed items array
getItemsKey()  : string|null
Get items key
getIterator()  : ArrayIterator
Return iterator
getPageKey()  : string|null
Get pake key
getString()  : string
Get text value
getUrl()  : string
Get full url
getUrlParams()  : array<string|int, mixed>|string
Get url params
has()  : bool
Return true if key exists in collection
isEmpty()  : bool
Return true if key exists and value not empty in collection
itemsKey()  : FeedCollection
Set items key
mapKey()  : FeedCollection
Change array key
merge()  : void
Merge collection items
mergeItems()  : void
Merge all collection items
offsetExists()  : bool
Return true if key exists in collection
offsetGet()  : mixed
Get item
offsetSet()  : void
Set item
offsetUnset()  : void
Remove item
pageKey()  : FeedCollection
Set page array key for params array
params()  : FeedCollection
Set params
perPageKey()  : FeedCollection
Set per page array key for params array
prepend()  : bool
Add value to begining of collection array
push()  : bool
Push value to collection
remove()  : Collection
Remove item
removeEmptyItems()  : void
Remove empy items
replace()  : Collection
Replace array
set()  : Collection
Set item value in collection
setArrayValue()  : array<string|int, mixed>
Set array value
setBooleanValue()  : void
Set bool value
setKeyMaps()  : void
Set key maps
setPage()  : void
Set feed current page
setPerPage()  : void
Set feed items per page
setValue()  : void
Set item value by path
slice()  : array<string|int, mixed>
Slice collecion by keys
toArray()  : array<string|int, mixed>
Return collection array
union()  : Collection
Union arrays
withData()  : Collection
Set collection data
getItemsArray()  : array<string|int, mixed>|null
Get items array
transformItem()  : array<string|int, mixed>
Transform item

Constants

Properties

$data

Collection items data

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

$keyMaps

Item key mappings

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

$params

Url params

protected array<string|int, mixed>|string $params

$perPageKey

Items per page array key

protected string|null $perPageKey

Methods

__construct()

Constructor

public __construct([string|null $baseUrl = null ][, array<string|int, mixed>|string $params = [] ][, string|null $itemsKey = null ][, string|null $pageKey = null ][, string|null $perPageKey = null ]) : mixed

@param string|null $baseUrl

Parameters
$baseUrl : string|null = null
$params : array<string|int, mixed>|string = []

@param string|null $itemsKey @param string|null $pageKey @param string|null $perPageKey

$itemsKey : string|null = null
$pageKey : string|null = null
$perPageKey : string|null = null

__get()

Get value

public __get(string $key) : mixed
Parameters
$key : string

__set()

Set value

public __set(string $key, mixed $value) : mixed
Parameters
$key : string
$value : mixed

add()

Add item to collection

public add(string $key, mixed $value) : void
Parameters
$key : string

key name

$value : mixed

addField()

Add value

public addField(string $path, mixed $value) : bool
Parameters
$path : string
$value : mixed
Return values
bool

applyKeyMaps()

Change item array keys

public applyKeyMaps([array<string|int, mixed>|null $items = null ]) : array<string|int, mixed>
Parameters
$items : array<string|int, mixed>|null = null
Return values
array<string|int, mixed>

clear()

Clear collection data

public clear() : void

copy()

Clone object

public copy() : self
Return values
self

count()

Return collection items count.

public count() : int
Return values
int

create()

Create colleciton

public static create(array<string|int, mixed> $data) : Collection
Parameters
$data : array<string|int, mixed>
Return values
Collection

createFromFile()

Create colection form json file

public static createFromFile(string $fileName[, string|null $root = null ][, array<string|int, mixed>|null $vars = null ]) : Collection
Parameters
$fileName : string
$root : string|null = null
$vars : array<string|int, mixed>|null = null
Return values
Collection

fetch()

Fetch feed

public fetch([int|null $page = null ][, int|null $perPage = Self::DEFAULT_ITEMS_PER_PAGE ]) : FeedCollection
Parameters
$page : int|null = null
$perPage : int|null = Self::DEFAULT_ITEMS_PER_PAGE
Return values
FeedCollection

findItem()

Find feed item

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

get()

Get value from collection

public get(string $key[, mixed $default = null ]) : mixed
Parameters
$key : string

Name

$default : mixed = null

If key not exists return default value

getArray()

Return array values

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

getBaseUrl()

Get base url

public getBaseUrl() : string
Return values
string

getBool()

Get boolean value

public getBool(string $key[, bool|null $default = null ]) : bool
Parameters
$key : string
$default : bool|null = null
Return values
bool

getByPath()

Get value by path

public getByPath(string $path[, mixed $default = null ]) : mixed
Parameters
$path : string
$default : mixed = null

getFloat()

Get float value

public getFloat(string $key[, float|null $default = null ]) : float|null
Parameters
$key : string
$default : float|null = null
Return values
float|null

getInt()

Get int value

public getInt(string $key[, int|null $default = null ]) : int|null
Parameters
$key : string
$default : int|null = null
Return values
int|null

getItem()

Get feed item

public getItem(int $index[, bool $keyMaps = true ]) : mixed
Parameters
$index : int
$keyMaps : bool = true

getItems()

Return feed items array

public getItems([bool $keyMaps = true ]) : array<string|int, mixed>
Parameters
$keyMaps : bool = true
Return values
array<string|int, mixed>

getItemsKey()

Get items key

public getItemsKey() : string|null
Return values
string|null

getIterator()

Return iterator

public getIterator() : ArrayIterator
Return values
ArrayIterator

getPageKey()

Get pake key

public getPageKey() : string|null
Return values
string|null

getString()

Get text value

public getString(string $key[, string|null $default = null ]) : string
Parameters
$key : string
$default : string|null = null
Return values
string

getUrl()

Get full url

public getUrl() : string
Return values
string

getUrlParams()

Get url params

public getUrlParams() : array<string|int, mixed>|string
Return values
array<string|int, mixed>|string

has()

Return true if key exists in collection

public has(string $key) : bool
Parameters
$key : string
Return values
bool

isEmpty()

Return true if key exists and value not empty in collection

public isEmpty(string $key) : bool
Parameters
$key : string

Name

Return values
bool

merge()

Merge collection items

public merge(string $key, array<string|int, mixed> $data[, bool $recursive = false ]) : void
Parameters
$key : string
$data : array<string|int, mixed>
$recursive : bool = false

mergeItems()

Merge all collection items

public mergeItems(array<string|int, mixed> $data[, bool $recursive = false ]) : void
Parameters
$data : array<string|int, mixed>
$recursive : bool = false

offsetExists()

Return true if key exists in collection

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool

offsetGet()

Get item

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed

offsetSet()

Set item

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed
$value : mixed

offsetUnset()

Remove item

public offsetUnset(mixed $offset) : void
Parameters
$offset : mixed

prepend()

Add value to begining of collection array

public prepend(string $key, mixed $value[, string|null $subKey = null ]) : bool
Parameters
$key : string
$value : mixed
$subKey : string|null = null
Return values
bool

push()

Push value to collection

public push(string $key, mixed $value[, string|null $subKey = null ]) : bool
Parameters
$key : string
$value : mixed
$subKey : string|null = null
Return values
bool

removeEmptyItems()

Remove empy items

public removeEmptyItems() : void

replace()

Replace array

public replace(array<string|int, mixed> $replacement) : Collection
Parameters
$replacement : array<string|int, mixed>
Return values
Collection

set()

Set item value in collection

public set(string $key, mixed $value) : Collection
Parameters
$key : string

Key Name

$value : mixed

Value

Return values
Collection

setArrayValue()

Set array value

public static setArrayValue(array<string|int, mixed> $array, string $path, mixed $value[, string $separator = '/' ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
$path : string
$value : mixed
$separator : string = '/'
Return values
array<string|int, mixed>

setBooleanValue()

Set bool value

public setBooleanValue(string $path, int|string $value) : void
Parameters
$path : string
$value : int|string

setKeyMaps()

Set key maps

public setKeyMaps(array<string|int, mixed> $keyMaps) : void
Parameters
$keyMaps : array<string|int, mixed>

setPage()

Set feed current page

public setPage(int $page) : void
Parameters
$page : int

setPerPage()

Set feed items per page

public setPerPage(int $perPage) : void
Parameters
$perPage : int

setValue()

Set item value by path

public setValue(string $path, mixed $value) : void
Parameters
$path : string
$value : mixed

slice()

Slice collecion by keys

public slice(array<string|int, mixed>|string $keys) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>|string
Return values
array<string|int, mixed>

toArray()

Return collection array

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

union()

Union arrays

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

withData()

Set collection data

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

getItemsArray()

Get items array

protected getItemsArray() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

transformItem()

Transform item

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

        
On this page

Search results