PHP 클래스 JBZoo\Data\Data

상속: extends ArrayObject
파일 보기 프로젝트 열기: jbzoo/data 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( array | string $data = [] ) Class constructor
__toString ( ) : string Magic method to convert the data to a string Returns a serialized version of the data contained in the data object using serialize()
find ( string $key, mixed $default = null, mixed $filter = null, string $separator = '.' ) : mixed Find a key in the data recursively This method finds the given key, searching also in any array or object that's nested under the current data object.
flattenRecursive ( ) : array Return flattened array copy. Keys are NOT preserved.
get ( string $key, mixed $default = null, mixed $filter = null ) : mixed Get a value from the data given its key
has ( string $name ) : boolean Checks if the given key is present
is ( string $key, mixed $compareWith = true, boolean $strictMode = false ) : boolean Compare value by key with somethig
offsetGet ( $index )
remove ( string $name ) Remove a value from the data
search ( mixed $needle ) : string | false Find a value also in nested arrays/objects
set ( string $name, mixed $value ) Set a value in the data
write ( ) : string Encode an array or an object in INI format

보호된 메소드들

메소드 설명
_decode ( string $string ) : mixed Utility Method to unserialize the given data
_encode ( mixed $data ) : string Utility Method to serialize the given data
_filter ( mixed $value, mixed $filter ) : mixed Filter value before return
_isMulti ( $array ) : boolean Check is array is nested
_readFile ( string $filePath ) : null | string

메소드 상세

__construct() 공개 메소드

Class constructor
public __construct ( array | string $data = [] )
$data array | string The data array

__toString() 공개 메소드

Magic method to convert the data to a string Returns a serialized version of the data contained in the data object using serialize()
public __toString ( ) : string
리턴 string

_decode() 보호된 메소드

Utility Method to unserialize the given data
protected _decode ( string $string ) : mixed
$string string
리턴 mixed

_encode() 보호된 메소드

Utility Method to serialize the given data
protected _encode ( mixed $data ) : string
$data mixed The data to serialize
리턴 string The serialized data

_filter() 보호된 메소드

Filter value before return
protected _filter ( mixed $value, mixed $filter ) : mixed
$value mixed
$filter mixed
리턴 mixed

_isMulti() 보호된 메소드

Check is array is nested
protected _isMulti ( $array ) : boolean
$array
리턴 boolean

_readFile() 보호된 메소드

protected _readFile ( string $filePath ) : null | string
$filePath string
리턴 null | string

find() 공개 메소드

Example: $data->find('parentkey.subkey.subsubkey');
public find ( string $key, mixed $default = null, mixed $filter = null, string $separator = '.' ) : mixed
$key string The key to search for. Can be composed using $separator as the key/subkey separator
$default mixed The default value
$filter mixed Filter returned value
$separator string The separator to use when searching for subkeys. Default is '.'
리턴 mixed

flattenRecursive() 공개 메소드

Return flattened array copy. Keys are NOT preserved.
public flattenRecursive ( ) : array
리턴 array

get() 공개 메소드

Get a value from the data given its key
public get ( string $key, mixed $default = null, mixed $filter = null ) : mixed
$key string The key used to fetch the data
$default mixed The default value
$filter mixed Filter returned value
리턴 mixed

has() 공개 메소드

Checks if the given key is present
public has ( string $name ) : boolean
$name string The key to check
리턴 boolean

is() 공개 메소드

Compare value by key with somethig
public is ( string $key, mixed $compareWith = true, boolean $strictMode = false ) : boolean
$key string
$compareWith mixed
$strictMode boolean
리턴 boolean

offsetGet() 공개 메소드

public offsetGet ( $index )

remove() 공개 메소드

Remove a value from the data
public remove ( string $name )
$name string The key of the data to remove

set() 공개 메소드

Set a value in the data
public set ( string $name, mixed $value )
$name string The key used to set the value
$value mixed The value to set

write() 공개 메소드

Encode an array or an object in INI format
public write ( ) : string
리턴 string