class PageHead extends Collection implements CollectionInterface, Countable, ArrayAccess, IteratorAggregate

Page head class

Properties

protected array $data Collection items data from Collection
protected array $params Property params

Methods

__construct(array $data = [])

Constructor

static Collection
create(array $data)

Create colleciton

static Collection
createFromFile(string $fileName, string|null $root = null, array|null $vars = null)

Create colection form json file

ArrayIterator
getIterator()

Return iterator

bool
has(string $key)

Return true if key exists in collection

bool
offsetExists(string $key)

Return true if key exists in collection

union(array $data)

Union arrays

replace(array $replacement)

Replace array

mixed
offsetGet(string $key)

Get item

void
offsetSet(string $key, mixed $value)

Set item

void
offsetUnset(string $key)

Remove item

remove(string $key)

Remove item

void
removeEmptyItems()

Remove empy items

integer
count()

Return collection items count.

void
setBooleanValue(string $path, integer|string $value)

Set bool value

void
setValue(string $path, mixed $value)

Set item value by path

void
merge(string $key, array $data, bool $recursive = false)

Merge collection items

void
mergeItems(array $data, bool $recursive = false)

Merge all collection items

Collection
set(string $key, mixed $value)

Set item value in collection

void
add(string $key, mixed $value)

Add item to collection

bool
push(string $key, mixed $value, string|null $subKey = null)

Push value to collection

bool
prepend(string $key, mixed $value, string|null $subKey = null)

Add value to begining of collection array

withData(array $data)

Set collection data

array
slice(array|string $keys)

Slice collecion by keys

array
toArray()

Return collection array

bool
isEmpty(string $key)

Return true if key exists and value not empty in collection

getCollection(string $key)

Get collection item

mixed
get(string $key, mixed $default = null)

Get value from collection

bool
getBool(string $key, bool|null $default = null)

Get boolean value

string|null
getString(string $key, string|null $default = null)

Get text value

int|null
getInt(string $key, int|null $default = null)

Get int value

float|null
getFloat(string $key, float|null $default = null)

Get float value

array
getArray(string $key, mixed $default = null)

Return array values

void
clear()

Clear collection data

Collection
copy()

Clone object

mixed
__get(string $key)

Get value

__set(string $key, mixed $value)

Set value

mixed
getByPath(string $path, mixed $default = null)

Get value by path

bool
addField(string $path, mixed $value)

Add value

array
getItems()

Get collection items

param(string $name, string $value)

Set property value param

array
getParams()

Get params

__call(string $name, array $arguments)

Add or set property

setMetaTags(array $data)

Set meta title, description and keywords

applyDefaultMetaTags(array $data)

Apply meta tags if values are empty

applyDefaultItems(array $items)

Set items value if not exist in collection

applyDefault(string $key, array $data)

Apply item value if is empty in collection

applyOgProperty(string $key, string $default = '')

Apply og property if value is not empty

applyTwitterProperty(string $key, string $default = '')

Apply twitter property if value is not empty

keywords(string|array ...$keywords)

Set keywords metatag

string
createKeywords(mixed ...$keywords)

Create keywords

applyDefaultKeywors(array ...$keywords)

Set keywords if field is empty

og(string $name, mixed $value, array $options = [])

Set Open Graph property

ogTitle(string|null $title = null)

Set Open Graph title property

ogDescription(string|null $description = null)

Set Open Graph description property

twitter(string $name, mixed $value, array $options = [])

Set twitter property

twitterTitle(string|null $title = null)

Set twitter title property

twitterDescription(string|null $description = null)

Set twitter description property

addProperty(string $key, string $name, string $value, array $options = [])

Add property

array
createProperty(string $name, string $value, array $options = [])

Create property array

bool
resolveProperties(string $key)

Resolve properties

Details

at line 34
__construct(array $data = [])

Constructor

Parameters

array $data

in Collection at line 45
static Collection create(array $data)

Create colleciton

Parameters

array $data

Return Value

Collection

in Collection at line 58
static Collection createFromFile(string $fileName, string|null $root = null, array|null $vars = null)

Create colection form json file

Parameters

string $fileName
string|null $root
array|null $vars

Return Value

Collection

in Collection at line 73
ArrayIterator getIterator()

Return iterator

Return Value

ArrayIterator

in Collection at line 84
bool has(string $key)

Return true if key exists in collection

Parameters

string $key

Return Value

bool

in Collection at line 95
bool offsetExists(string $key)

Return true if key exists in collection

Parameters

string $key

Return Value

bool

in Collection at line 106
Collection union(array $data)

Union arrays

Parameters

array $data

Return Value

Collection

in Collection at line 119
Collection replace(array $replacement)

Replace array

Parameters

array $replacement

Return Value

Collection

in Collection at line 132
mixed offsetGet(string $key)

Get item

Parameters

string $key

Return Value

mixed

in Collection at line 144
void offsetSet(string $key, mixed $value)

Set item

Parameters

string $key
mixed $value

Return Value

void

in Collection at line 155
void offsetUnset(string $key)

Remove item

Parameters

string $key

Return Value

void

in Collection at line 166
Collection remove(string $key)

Remove item

Parameters

string $key

Return Value

Collection

in Collection at line 178
void removeEmptyItems()

Remove empy items

Return Value

void

in Collection at line 190
integer count()

Return collection items count.

Return Value

integer

in Collection at line 202
void setBooleanValue(string $path, integer|string $value)

Set bool value

Parameters

string $path
integer|string $value

Return Value

void

in Collection at line 221
void setValue(string $path, mixed $value)

Set item value by path

Parameters

string $path
mixed $value

Return Value

void

in Collection at line 234
void merge(string $key, array $data, bool $recursive = false)

Merge collection items

Parameters

string $key
array $data
bool $recursive

Return Value

void

in Collection at line 249
void mergeItems(array $data, bool $recursive = false)

Merge all collection items

Parameters

array $data
bool $recursive

Return Value

void

in Collection at line 261
Collection set(string $key, mixed $value)

Set item value in collection

Parameters

string $key Key Name
mixed $value Value

Return Value

Collection

in Collection at line 275
void add(string $key, mixed $value)

Add item to collection

Parameters

string $key key name
mixed $value

Return Value

void

in Collection at line 292
bool push(string $key, mixed $value, string|null $subKey = null)

Push value to collection

Parameters

string $key
mixed $value
string|null $subKey

Return Value

bool

in Collection at line 319
bool prepend(string $key, mixed $value, string|null $subKey = null)

Add value to begining of collection array

Parameters

string $key
mixed $value
string|null $subKey

Return Value

bool

in Collection at line 343
Collection withData(array $data)

Set collection data

Parameters

array $data

Return Value

Collection

in Collection at line 356
array slice(array|string $keys)

Slice collecion by keys

Parameters

array|string $keys

Return Value

array

in Collection at line 366
array toArray()

Return collection array

Return Value

array

in Collection at line 377
bool isEmpty(string $key)

Return true if key exists and value not empty in collection

Parameters

string $key

Return Value

bool

in Collection at line 388
Collection getCollection(string $key)

Get collection item

Parameters

string $key

Return Value

Collection

in Collection at line 400
mixed get(string $key, mixed $default = null)

Get value from collection

Parameters

string $key Name
mixed $default If key not exists return default value

Return Value

mixed

in Collection at line 412
bool getBool(string $key, bool|null $default = null)

Get boolean value

Parameters

string $key
bool|null $default

Return Value

bool

in Collection at line 424
string|null getString(string $key, string|null $default = null)

Get text value

Parameters

string $key
string|null $default

Return Value

string|null

in Collection at line 438
int|null getInt(string $key, int|null $default = null)

Get int value

Parameters

string $key
int|null $default

Return Value

int|null

in Collection at line 452
float|null getFloat(string $key, float|null $default = null)

Get float value

Parameters

string $key
float|null $default

Return Value

float|null

in Collection at line 466
array getArray(string $key, mixed $default = null)

Return array values

Parameters

string $key
mixed $default

Return Value

array

in Collection at line 478
void clear()

Clear collection data

Return Value

void

in Collection at line 488
Collection copy()

Clone object

Return Value

Collection

in Collection at line 499
mixed __get(string $key)

Get value

Parameters

string $key

Return Value

mixed

in Collection at line 510
__set(string $key, mixed $value)

Set value

Parameters

string $key
mixed $value

in Collection at line 522
mixed getByPath(string $path, mixed $default = null)

Get value by path

Parameters

string $path
mixed $default

Return Value

mixed

in Collection at line 536
bool addField(string $path, mixed $value)

Add value

Parameters

string $path
mixed $value

Return Value

bool

in Collection at line 555
array getItems()

Get collection items

Return Value

array

at line 50
PageHead param(string $name, string $value)

Set property value param

Parameters

string $name
string $value

Return Value

PageHead

at line 62
array getParams()

Get params

Return Value

array

at line 74
PageHead __call(string $name, array $arguments)

Add or set property

Parameters

string $name
array $arguments

Return Value

PageHead

at line 97
PageHead setMetaTags(array $data)

Set meta title, description and keywords

Parameters

array $data

Return Value

PageHead

at line 112
PageHead applyDefaultMetaTags(array $data)

Apply meta tags if values are empty

Parameters

array $data

Return Value

PageHead

at line 127
PageHead applyDefaultItems(array $items)

Set items value if not exist in collection

Parameters

array $items

Return Value

PageHead

at line 145
PageHead applyDefault(string $key, array $data)

Apply item value if is empty in collection

Parameters

string $key
array $data

Return Value

PageHead

at line 162
PageHead applyOgProperty(string $key, string $default = '')

Apply og property if value is not empty

Parameters

string $key
string $default

Return Value

PageHead

at line 179
PageHead applyTwitterProperty(string $key, string $default = '')

Apply twitter property if value is not empty

Parameters

string $key
string $default

Return Value

PageHead

at line 195
PageHead keywords(string|array ...$keywords)

Set keywords metatag

Parameters

string|array ...$keywords

Return Value

PageHead

at line 208
string createKeywords(mixed ...$keywords)

Create keywords

Parameters

mixed ...$keywords

Return Value

string

at line 225
PageHead applyDefaultKeywors(array ...$keywords)

Set keywords if field is empty

Parameters

array ...$keywords

Return Value

PageHead

at line 242
PageHead og(string $name, mixed $value, array $options = [])

Set Open Graph property

Parameters

string $name
mixed $value
array $options

Return Value

PageHead

at line 253
PageHead ogTitle(string|null $title = null)

Set Open Graph title property

Parameters

string|null $title

Return Value

PageHead

at line 266
PageHead ogDescription(string|null $description = null)

Set Open Graph description property

Parameters

string|null $description

Return Value

PageHead

at line 281
PageHead twitter(string $name, mixed $value, array $options = [])

Set twitter property

Parameters

string $name
mixed $value
array $options

Return Value

PageHead

at line 292
PageHead twitterTitle(string|null $title = null)

Set twitter title property

Parameters

string|null $title

Return Value

PageHead

at line 305
PageHead twitterDescription(string|null $description = null)

Set twitter description property

Parameters

string|null $description

Return Value

PageHead

at line 321
protected PageHead addProperty(string $key, string $name, string $value, array $options = [])

Add property

Parameters

string $key
string $name
string $value
array $options

Return Value

PageHead

at line 337
protected array createProperty(string $name, string $value, array $options = [])

Create property array

Parameters

string $name
string $value
array $options

Return Value

array

at line 352
bool resolveProperties(string $key)

Resolve properties

Parameters

string $key

Return Value

bool