PHP Classes
elePHPant
Icontem

Fuse Array: Manage arrays with read only properties

Recommend this page to a friend!
  Info   View files Example   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2014-07-27 (2 years ago) RSS 2.0 feedStarStarStar 40%Total: 244 All time: 7,417 This week: 1,125Up
Version License PHP version Categories
fuse-array 1.0.0BSD License5.3PHP 5, Data types
Description Author

This class can manage arrays with read only properties.

It implements the ArrayAccess interface so its objects can be manipulated as if they are arrays of value elements.

The class can make certain array entries read-only, so it throws an exception if an application attempts to change the values of those entries.

Innovation Award
PHP Programming Innovation award nominee
July 2014
Number 4


Prize: One downloadable copy of Komodo IDE
Sometimes it is necessary to prevent that applications change the values of certain array entries.

This class implements the array access interface to emulate array values that may have certain entries disabled for change.

This way it can detect and prevent that applications attempt to change read-only array entry values.

Manuel Lemos
Picture of Thomas Björk
  Performance   Level  
Name: Thomas Björk <contact>
Classes: 11 packages by
Country: Sweden Sweden
Age: 48
All time rank: 1641 in Sweden Sweden
Week rank: 103 Up1 in Sweden Sweden Equal
Innovation award
Innovation award
Nominee: 3x

Details

FuseArray

FuseArray is an implementation of an array with read-only capabilities.

Functions

public function Get($name)

A plain get-function. Identical to __get

public function Set($name, $value, $fuseOut = false)

An extended set-function which alse has the ability to set the property as read-only. If $fuseOut is set to true then the property will be read-only.

public function FuseOut($name)

FuseOut will set the property defined by $name as read-only.

public static function Convert($data, $fuseOut = false)

Convert is a static conservsion to FuseArray from a standard array or another FuseArray.

public function Import($data, $fuseOut = false)

Import is a dynamic conservsion to FuseArray from a standard array or another FuseArray.

Implemented functions

These functions are either basic functions in the class or functions for the implemented interfaces.

public function __construct()

public function __destruct()

public function __get($name)

public function __set($name, $value)

public function count()

public function offsetExists($offset)

public function offsetGet($offset)

public function offsetSet($offset, $value)

public function offsetUnset($offset)

public function serialize()

public function unserialize($serialized)

public function current()

public function key()

public function next()

public function prev()

public function rewind()

public function valid()

Usage

Can be used more or less as a standard array in many cases. The array functions in PHP (array_\*) will not work since the arrays produced by FuseArray are objects and not real arrays.

ConfigArray

ConfigArray is an extend of FuseArray which implements a simple way to handle configurations based on ini-files.

Functions

public static function ConvertIni($iniData, $fuseOut = true)

ConvertIni is a static method that will take either an dual layered array or a filename as its first argument and convert this into an config array.

[section]
property=value

Will be converted into

section.property=value

public function ImportIni($iniData, $fuseOut = true)

ImportIni is a dynamic method that will take either an dual layered array or a filename as its first argument and convert this into an config array.

[section]
property=value

Will be converted into

section.property=value

Repositories

This package can be found at the following places.

PHPClasses.org

http://www.phpclasses.org/fuse-array

GitHub

https://github.com/ultrix3x/FuseArray

  Files folder image Files  
File Role Description
Files folder imageexamples (5 files)
Files folder imageextends (1 file)
Plain text file fusearray.php Class Main file with class
Accessible without login Plain text file LICENSE Data New license file
Accessible without login Plain text file README.md Data Changed format of the readme from readme.txt to readme.md

  Files folder image Files  /  examples  
File Role Description
  Accessible without login Plain text file exampleConfig.ini Data Example ini-file used by the example
  Accessible without login Plain text file exampleConfig.php Example Example to read ini-file to use as an config
  Accessible without login Plain text file exampleConvert.php Example Example on how to load data statically
  Accessible without login Plain text file exampleFail.php Example Example on how not to use the class
  Accessible without login Plain text file exampleImport.php Example Example on how to load data dynamically

  Files folder image Files  /  extends  
File Role Description
  Plain text file configarray.php Class En extend that reads and parses ini-files

 Version Control Reuses Unique User Downloads Download Rankings  
 100%1
Total:244
This week:0
All time:7,417
This week:1,125Up
 User Ratings  
 
 All time
Utility:58%StarStarStar
Consistency:50%StarStarStar
Documentation:-
Examples:66%StarStarStarStar
Tests:-
Videos:-
Overall:40%StarStarStar
Rank:2480