Class Ice

Arr

Access class as array and the same time as object.
Methods
__construct(array $data)
Arr constructor.
bool
has(string $key)
Whether or not a data exists by key.
get(string $key, variable $defaultValue)
Retrieve a single key from an array.
set(string $key, variable $value)
Assigns a value to the specified data.
replace(array $data)
Add data to set, replaces the existing data.
array
all()
Fetch all data.
array
only(array $keys, bool $strict)
Fetch some data.
getValue(string $key, variable $filters, variable $defaultValue, bool $allowEmpty)
Gets value from data applying filters if needed.
setData(array $data)
Set data, clears and overwrites the current data.
array
keys()
Fetch set data keys.
remove(string $key)
Remove a data by key.
clear()
Clear all values.
int
count()
Count all elements in a data.
getIterator()
Get a data iterator.
getPath(variable $path, variable $defaultValue, string $delimiter)
Gets a value from an array using a dot separated path.
array
toArray()
Converts recursively the object to an array.
bool
offsetExists(variable $offset)
Whether or not an offset exists.
offsetGet(variable $offset)
Returns the value at specified offset.
offsetSet(variable $offset, variable $value)
Assigns a value to the specified offset.
offsetUnset(variable $offset)
Unsets an offset.
bool
__isset(string $key)
Magic isset, whether or not a key exists.
__get(variable $key)
Magic get, returns the value at specified key.
__set(string $key, variable $value)
Magic set, assigns a value to the specified key.
__unset(variable $key)
Magic unset, unsets a key.
Methods Details
  • public function getData()

  • public function __construct(array $data)

    Arr constructor.
  • public function has(string $key)

    Whether or not a data exists by key.
  • public function get(string $key, variable $defaultValue)

    Retrieve a single key from an array.
    If the key does not exist in the array, the default value will be returned.
  • public function set(string $key, variable $value)

    Assigns a value to the specified data.
  • public function replace(array $data)

    Add data to set, replaces the existing data.
  • public function all()

    Fetch all data.
  • public function only(array $keys, bool $strict)

    Fetch some data.
  • public function getValue(string $key, variable $filters, variable $defaultValue, bool $allowEmpty)

    Gets value from data applying filters if needed.
    
          //Returns value from $arr["id"] without sanitizing
          $id = $arr->getValue("id");
         
          //Returns value from $arr["title"] with sanitizing
          $title = $arr->getValue("title", "escape|repeats");
         
          //Returns value from $arr["id"] with a default value
          $id = $arr->getValue("id", null, 150);
         
  • public function setData(array $data)

    Set data, clears and overwrites the current data.
  • public function keys()

    Fetch set data keys.
  • public function remove(string $key)

    Remove a data by key.
  • public function clear()

    Clear all values.
  • public function count()

    Count all elements in a data.
  • public function getIterator()

    Get a data iterator.
    return ArrayIterator
  • public function getPath(variable $path, variable $defaultValue, string $delimiter)

    Gets a value from an array using a dot separated path.
    
          // Get the value of $array['foo']['bar']
          $value = (new Arr($array))->getPath('foo.bar');
         
    
          // Get the values of "color" in theme
          $colors = (new Arr($array))->getPath('theme..color');
         
  • public function toArray()

    Converts recursively the object to an array.
  • public function offsetExists(variable $offset)

    Whether or not an offset exists.
  • public function offsetGet(variable $offset)

    Returns the value at specified offset.
  • public function offsetSet(variable $offset, variable $value)

    Assigns a value to the specified offset.
  • public function offsetUnset(variable $offset)

    Unsets an offset.
  • public function __isset(string $key)

    Magic isset, whether or not a key exists.
  • public function __get(variable $key)

    Magic get, returns the value at specified key.
    First check if property exist.
  • public function __set(string $key, variable $value)

    Magic set, assigns a value to the specified key.
    First check if property exist.
  • public function __unset(variable $key)

    Magic unset, unsets a key.
  • internal function zephir_init_properties_Ice_Arr()