PageHead
extends Collection
in package
implements
CollectionInterface, Countable, ArrayAccess, IteratorAggregate
Page head class
Table of Contents
Interfaces
- CollectionInterface
- Collection interface
- Countable
- ArrayAccess
- IteratorAggregate
Constants
- END_OF_LINE = "\n\t\t"
- Added to each html tag
Properties
- $data : array<string|int, mixed>
- Collection items data
- $htmlCode : string
- Page head html code
- $params : array<string|int, mixed>
- Property params
Methods
- __call() : PageHead
- Add or set property
- __construct() : mixed
- Constructor
- __get() : mixed
- Get value
- __set() : mixed
- Set value
- add() : void
- Add item to collection
- addCommentCode() : void
- Add ccomment code
- addComponentFileCode() : void
- Add component file code
- addComponentInstanceCode() : void
- Add comoponent instance code
- addField() : bool
- Add value
- addHtmlCode() : void
- Add head html code
- addInlineScriptCode() : void
- Add inline script code
- addLibraryIncludeCode() : void
- Add library include code
- addLinkCode() : void
- Add link code
- addMetaTag() : void
- Add metatag code
- addMetaTagCodeForItems() : void
- Add meta code fro items
- addScriptCode() : void
- Add script code
- applyDefault() : PageHead
- Apply item value if is empty in collection
- applyDefaultKeywors() : PageHead
- Set keywords if field is empty
- applyDefaultMetaTags() : PageHead
- Apply meta tags if values are empty
- applyOgProperty() : PageHead
- Apply og property if value is not empty
- applyTwitterProperty() : PageHead
- Apply twitter property if value is not empty
- 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
- createInlineScriptCode() : string
- Create inline script code
- createKeywords() : string
- Create keywords
- get() : mixed
- Get value from collection
- getArray() : array<string|int, mixed>
- Return array values
- getBool() : bool
- Get boolean value
- getByPath() : mixed
- Get value by path
- getCollection() : Collection
- Get collection item
- getFloat() : float|null
- Get float value
- getHtmlCode() : string
- Get html code
- getInt() : int|null
- Get int value
- getItems() : array<string|int, mixed>
- Get collection items
- getIterator() : ArrayIterator
- Return iterator
- getLinkCode() : string
- Create link code
- getMetaCode() : string
- Get metatag html code
- getParams() : array<string|int, mixed>
- Get params
- getScriptCode() : string
- Create script code
- getString() : string
- Get text value
- has() : bool
- Return true if key exists in collection
- isEmpty() : bool
- Return true if key exists and value not empty in collection
- keywords() : PageHead
- Set keywords metatag
- 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
- og() : PageHead
- Set Open Graph property
- ogDescription() : PageHead
- Set Open Graph description property
- ogTitle() : PageHead
- Set Open Graph title property
- param() : PageHead
- Set property value param
- 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
- resolveProperties() : bool
- Resolve properties
- set() : Collection
- Set item value in collection
- setArrayValue() : array<string|int, mixed>
- Set array value
- setBooleanValue() : void
- Set bool value
- setMetaTags() : PageHead
- Set meta title, description and keywords
- setValue() : void
- Set item value by path
- slice() : array<string|int, mixed>
- Slice collecion by keys
- toArray() : array<string|int, mixed>
- Return page head as array
- twitter() : PageHead
- Set twitter property
- twitterDescription() : PageHead
- Set twitter description property
- twitterTitle() : PageHead
- Set twitter title property
- union() : Collection
- Union arrays
- withData() : Collection
- Set collection data
- addProperty() : PageHead
- Add property
- createProperty() : array<string|int, mixed>
- Create property array
Constants
END_OF_LINE
Added to each html tag
public
mixed
END_OF_LINE
= "\n\t\t"
Properties
$data
Collection items data
protected
array<string|int, mixed>
$data
= []
$htmlCode
Page head html code
protected
string
$htmlCode
$params
Property params
protected
array<string|int, mixed>
$params
Methods
__call()
Add or set property
public
__call(string $name, array<string|int, mixed> $arguments) : PageHead
Parameters
- $name : string
- $arguments : array<string|int, mixed>
Return values
PageHead__construct()
Constructor
public
__construct([array<string|int, mixed> $data = [] ]) : mixed
Parameters
- $data : array<string|int, mixed> = []
__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
addCommentCode()
Add ccomment code
public
addCommentCode(string $comment) : void
Parameters
- $comment : string
addComponentFileCode()
Add component file code
public
addComponentFileCode(array<string|int, mixed> $file) : void
Parameters
- $file : array<string|int, mixed>
addComponentInstanceCode()
Add comoponent instance code
public
addComponentInstanceCode(array<string|int, mixed> $item) : void
Parameters
- $item : array<string|int, mixed>
addField()
Add value
public
addField(string $path, mixed $value) : bool
Parameters
- $path : string
- $value : mixed
Return values
booladdHtmlCode()
Add head html code
public
addHtmlCode(string $code) : void
Parameters
- $code : string
addInlineScriptCode()
Add inline script code
public
addInlineScriptCode(string $content[, string $type = 'text/javascript' ][, string $attr = '' ]) : void
Parameters
- $content : string
- $type : string = 'text/javascript'
- $attr : string = ''
addLibraryIncludeCode()
Add library include code
public
addLibraryIncludeCode(array<string|int, mixed> $file) : void
Parameters
- $file : array<string|int, mixed>
addLinkCode()
Add link code
public
addLinkCode(string $href, string $type[, string $rel = '' ][, string $media = 'all' ][, string $onload = '' ][, string $attr = '' ]) : void
Parameters
- $href : string
- $type : string
- $rel : string = ''
- $media : string = 'all'
- $onload : string = ''
- $attr : string = ''
addMetaTag()
Add metatag code
public
addMetaTag(string $name, string $value) : void
Parameters
- $name : string
- $value : string
addMetaTagCodeForItems()
Add meta code fro items
public
addMetaTagCodeForItems(array<string|int, mixed> $items) : void
Parameters
- $items : array<string|int, mixed>
addScriptCode()
Add script code
public
addScriptCode(string $src[, string $type = '' ][, string $id = '' ][, string $attr = '' ]) : void
Parameters
- $src : string
- $type : string = ''
- $id : string = ''
- $attr : string = ''
applyDefault()
Apply item value if is empty in collection
public
applyDefault(string $key, array<string|int, mixed> $data) : PageHead
Parameters
- $key : string
- $data : array<string|int, mixed>
Return values
PageHeadapplyDefaultKeywors()
Set keywords if field is empty
public
applyDefaultKeywors(array<string|int, mixed> ...$keywords) : PageHead
Parameters
- $keywords : array<string|int, mixed>
Return values
PageHeadapplyDefaultMetaTags()
Apply meta tags if values are empty
public
applyDefaultMetaTags(array<string|int, mixed> $data) : PageHead
Parameters
- $data : array<string|int, mixed>
Return values
PageHeadapplyOgProperty()
Apply og property if value is not empty
public
applyOgProperty(string $key[, string $default = '' ]) : PageHead
Parameters
- $key : string
- $default : string = ''
Return values
PageHeadapplyTwitterProperty()
Apply twitter property if value is not empty
public
applyTwitterProperty(string $key[, string $default = '' ]) : PageHead
Parameters
- $key : string
- $default : string = ''
Return values
PageHeadclear()
Clear collection data
public
clear() : void
copy()
Clone object
public
copy() : self
Return values
selfcount()
Return collection items count.
public
count() : int
Return values
intcreate()
Create colleciton
public
static create(array<string|int, mixed> $data) : Collection
Parameters
- $data : array<string|int, mixed>
Return values
CollectioncreateFromFile()
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
CollectioncreateInlineScriptCode()
Create inline script code
public
createInlineScriptCode(string $content[, string $type = 'text/javascript' ][, string $attr = '' ]) : string
Parameters
- $content : string
- $type : string = 'text/javascript'
- $attr : string = ''
Return values
stringcreateKeywords()
Create keywords
public
createKeywords(mixed ...$keywords) : string
Parameters
- $keywords : mixed
Return values
stringget()
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>getBool()
Get boolean value
public
getBool(string $key[, bool|null $default = null ]) : bool
Parameters
- $key : string
- $default : bool|null = null
Return values
boolgetByPath()
Get value by path
public
getByPath(string $path[, mixed $default = null ]) : mixed
Parameters
- $path : string
- $default : mixed = null
getCollection()
Get collection item
public
getCollection(string $key) : Collection
Parameters
- $key : string
Return values
CollectiongetFloat()
Get float value
public
getFloat(string $key[, float|null $default = null ]) : float|null
Parameters
- $key : string
- $default : float|null = null
Return values
float|nullgetHtmlCode()
Get html code
public
getHtmlCode() : string
Return values
stringgetInt()
Get int value
public
getInt(string $key[, int|null $default = null ]) : int|null
Parameters
- $key : string
- $default : int|null = null
Return values
int|nullgetItems()
Get collection items
public
getItems() : array<string|int, mixed>
Return values
array<string|int, mixed>getIterator()
Return iterator
public
getIterator() : ArrayIterator
Return values
ArrayIteratorgetLinkCode()
Create link code
public
getLinkCode(string $href, string $type[, string $rel = '' ][, string $media = 'all' ][, string $onload = '' ][, string $attr = '' ]) : string
Parameters
- $href : string
- $type : string
- $rel : string = ''
- $media : string = 'all'
- $onload : string = ''
- $attr : string = ''
Return values
stringgetMetaCode()
Get metatag html code
public
getMetaCode(string $name, string $value[, string $keyName = 'name' ]) : string
Parameters
- $name : string
- $value : string
- $keyName : string = 'name'
Return values
stringgetParams()
Get params
public
getParams() : array<string|int, mixed>
Return values
array<string|int, mixed>getScriptCode()
Create script code
public
getScriptCode(string $src[, string $type = '' ][, string $id = '' ][, string $attr = '' ]) : string
Parameters
- $src : string
- $type : string = ''
- $id : string = ''
- $attr : string = ''
Return values
stringgetString()
Get text value
public
getString(string $key[, string|null $default = null ]) : string
Parameters
- $key : string
- $default : string|null = null
Return values
stringhas()
Return true if key exists in collection
public
has(string $key) : bool
Parameters
- $key : string
Return values
boolisEmpty()
Return true if key exists and value not empty in collection
public
isEmpty(string $key) : bool
Parameters
- $key : string
-
Name
Return values
boolkeywords()
Set keywords metatag
public
keywords(string|array<string|int, mixed> ...$keywords) : PageHead
Parameters
- $keywords : string|array<string|int, mixed>
Return values
PageHeadmerge()
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
booloffsetGet()
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
og()
Set Open Graph property
public
og(string $name, mixed $value[, array<string|int, mixed> $options = [] ]) : PageHead
Parameters
- $name : string
- $value : mixed
- $options : array<string|int, mixed> = []
Return values
PageHeadogDescription()
Set Open Graph description property
public
ogDescription([string|null $description = null ]) : PageHead
Parameters
- $description : string|null = null
Return values
PageHeadogTitle()
Set Open Graph title property
public
ogTitle([string|null $title = null ]) : PageHead
Parameters
- $title : string|null = null
Return values
PageHeadparam()
Set property value param
public
param(string $name, mixed $value) : PageHead
Parameters
- $name : string
- $value : mixed
Return values
PageHeadprepend()
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
boolpush()
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
boolremove()
Remove item
public
remove(string $key) : Collection
Parameters
- $key : string
Return values
CollectionremoveEmptyItems()
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
CollectionresolveProperties()
Resolve properties
public
resolveProperties(string $key) : bool
Parameters
- $key : string
Return values
boolset()
Set item value in collection
public
set(string $key, mixed $value) : Collection
Parameters
- $key : string
-
Key Name
- $value : mixed
-
Value
Return values
CollectionsetArrayValue()
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
setMetaTags()
Set meta title, description and keywords
public
setMetaTags(array<string|int, mixed> $data) : PageHead
Parameters
- $data : array<string|int, mixed>
Return values
PageHeadsetValue()
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 page head as array
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>twitter()
Set twitter property
public
twitter(string $name, mixed $value[, array<string|int, mixed> $options = [] ]) : PageHead
Parameters
- $name : string
- $value : mixed
- $options : array<string|int, mixed> = []
Return values
PageHeadtwitterDescription()
Set twitter description property
public
twitterDescription([string|null $description = null ]) : PageHead
Parameters
- $description : string|null = null
Return values
PageHeadtwitterTitle()
Set twitter title property
public
twitterTitle([string|null $title = null ]) : PageHead
Parameters
- $title : string|null = null
Return values
PageHeadunion()
Union arrays
public
union(array<string|int, mixed> $data) : Collection
Parameters
- $data : array<string|int, mixed>
Return values
CollectionwithData()
Set collection data
public
withData(array<string|int, mixed> $data) : Collection
Parameters
- $data : array<string|int, mixed>
Return values
CollectionaddProperty()
Add property
protected
addProperty(string $key, string $name, string $value[, array<string|int, mixed> $options = [] ]) : PageHead
Parameters
- $key : string
- $name : string
- $value : string
- $options : array<string|int, mixed> = []
Return values
PageHeadcreateProperty()
Create property array
protected
createProperty(string $name, string $value[, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $name : string
- $value : string
- $options : array<string|int, mixed> = []