ConfigParser/BaseConfigParser.php

Classes 
author
Vítor Brandão <noisebleed@noiselabs.org>
category
NoiseLabs
copyright
(C) 2011 Vítor Brandão <noisebleed@noiselabs.org>
package
ConfigParser
version
0.1.1
Classes
BaseConfigParser

Description

This file is part of NoiseLabs-PHP-ToolKit

NoiseLabs-PHP-ToolKit is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

NoiseLabs-PHP-ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with NoiseLabs-PHP-ToolKit; if not, see http://www.gnu.org/licenses/.

Copyright (C) 2011 Vítor Brandão noisebleed@noiselabs.org

NoiseLabs\ToolKit\ConfigParser\BaseConfigParser

Implements
Constants
VERSION
Properties
$settings
$_defaults
$_sections
$_files
$_boolean_states
Methods
__construct
defaults
_read
read
readFile
readString
readArray
reload
_buildOutputString
write
getIterator
count
save
clear
dump
removeSection
offsetExists
offsetGet
offsetSet
offsetUnset
log
_throwExceptions

Constants

VERSION

 VERSION = '0.1.0'

Details

value
0.1.0

Properties

$_boolean_states

array $_boolean_states = 'array'

Booleans alias

Details

$_boolean_states
array
visibility
protected
default
array
final
false
static
false

$_defaults

array $_defaults = 'array'

Details

$_defaults
array
visibility
protected
default
array
final
false
static
false

$_files

array $_files = 'array'

An array of FILE objects representing the loaded files.

Details

$_files
array
visibility
protected
default
array
final
false
static
false

$_sections

array $_sections = 'array'

The configuration representation is stored here.

Details

$_sections
array
visibility
protected
default
array
final
false
static
false

$settings

 $settings = 'array'

A set of internal options used when parsing and writing files.

Known settings:

'delimiter': The delimiter character to use between keys and values. Defaults to '='.

'space_around_delimiters': Put a blank space between keys/values and delimiters? Defaults to TRUE.

'linebreak': The linebreak to use. Defaults to '\r\n' on Windows OS and '\n' on every other OS.

'interpolation':

Details

visibility
public
default
array
final
false
static
false
todo

Methods

__construct

__construct( array $defaults = array, array $settings = array ) :

Constructor.

Arguments
$defaults
array
$settings
array
Details
visibility
public
final
false
static
false

_buildOutputString

_buildOutputString( ) :
Details
visibility
protected
final
false
static
false

_read

_read(  $filename ) :

Note the usage of INI_SCANNER_RAW to avoid parser_ini_files from parsing options and transforming 'false' values to empty strings.

Arguments
$filename
Details
visibility
protected
final
false
static
false

_throwExceptions

_throwExceptions( ) :
Details
visibility
protected
final
false
static
false

clear

clear( ) : void

Removes all parsed data.

Details
visibility
public
final
false
static
false

count

count( ) : integer

Returns the number of sections (implements the \Countable interface).

Output
integer
The number of sections
Details
visibility
public
final
false
static
false

defaults

defaults( ) :

Return an associative array containing the instance-wide defaults.

Details
visibility
public
final
false
static
false

dump

dump( ) : void

Output the current configuration representation.

Details
visibility
public
final
false
static
false

getIterator

getIterator( ) : \ArrayIterator

Returns the iterator for this group.

Output
\ArrayIterator
Details
visibility
public
final
false
static
false

log

log(  $message,  $level = crit ) :
Arguments
$message
$level
Details
visibility
public
final
false
static
false

offsetExists

offsetExists( string $offset ) : Boolean

Returns true if the section exists (implements the \ArrayAccess interface).

Arguments
$offset
string
The name of the section
Output
Boolean
true if the section exists, false otherwise
Details
visibility
public
final
false
static
false

offsetGet

offsetGet( string $offset ) : mixed

Returns the array of options associated with the section (implements the \ArrayAccess interface).

Arguments
$offset
string
The offset of the value to get
Output
mixed
The array of options associated with the section
Details
visibility
public
final
false
static
false

offsetSet

offsetSet(  $offset,  $value ) :

Adds an array of options to the given section (implements the \ArrayAccess interface).

Arguments
$offset
$value
Details
visibility
public
final
false
static
false

offsetUnset

offsetUnset( string $name ) :

Removes the child with the given name from the form (implements the \ArrayAccess interface).

Arguments
$name
string
The name of the child to be removed
Details
visibility
public
final
false
static
false

read

read(  $filenames = array ) :

Attempt to read and parse a list of filenames, returning a list of filenames which were successfully parsed. If filenames is a string, it is treated as a single filename. If a file named in filenames cannot be opened, that file will be ignored. This is designed so that you can specify a list of potential configuration file locations (for example, the current directory, the user’s home directory, and some system-wide directory), and all existing configuration files in the list will be read. If none of the named files exist, the ConfigParser instance will contain an empty dataset. An application which requires initial values to be loaded from a file should load the required file or files using read_file() before calling read() for any optional files:

Arguments
$filenames
Details
visibility
public
final
false
static
false

readArray

readArray(  $array = array ) :
Arguments
$array
Details
visibility
public
final
false
static
false

readFile

readFile(  $filehandler ) :
Arguments
$filehandler
Details
visibility
public
final
false
static
false

readString

readString(  $string ) :
Arguments
$string
Details
visibility
public
final
false
static
false

reload

reload( ) :

Re-read configuration from all successfully parsed files.

Details
visibility
public
final
false
static
false

removeSection

removeSection(  $section ) :

Remove the specified section from the configuration. If the section in fact existed, return TRUE. Otherwise return FALSE.

Arguments
$section
Details
visibility
public
final
false
static
false

save

save( ) :

Write the stored configuration to the last file successfully parsed in $this->read().

Details
visibility
public
final
false
static
false

write

write(  $filename ) :

Write an .ini-format representation of the configuration state

Arguments
$filename
Details
visibility
public
final
false
static
false
throws
if file is not writable
Documentation was generated by DocBlox.