2017 © Pedro Peláez
 

library fluent-configuration

A fluent configuration trait for PHP

image

emaphp/fluent-configuration

A fluent configuration trait for PHP

  • Monday, February 23, 2015
  • by emaphp
  • Repository
  • 1 Watchers
  • 1 Stars
  • 71 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

fluent-configuration

A fluent configuration trait for PHP, (*1)

Build Status, (*2)

br/, (*3)

Changelog

2014-02-23 * Modified: Method 'append' renamed to push. * Added: Method 'pop'., (*4)

br/, (*5)

Installation

composer.json, (*6)

{
    "require": {
        "emaphp/fluent-configuration": "1.2.*"
    }
}

br/, (*7)

Usage

br/ Include trait, (*8)

namespace Demo;

class ConfigurationContainer {
    use \FluentConfiguration;
}

br/ Examples, (*9)

use Demo\ConfigurationContainer;

$config = new ConfigurationContainer();

//set option
$config->setOption('test1', 'value1');
$option = $config->getOption('test1'); // 'value1'

//fluent interface
$newInstance = $config->option('test2', 'value2')->option('test3', 'value3');
$newInstance->getOption('test2'); // 'value2'
$config->hasOption('test2'); //false
$config->hasOption('test3'); //false

//merge options
$config = $newInstance->merge(['test3' => 'new_value', 'test4' => 'value4']);
$config->getOption('test1'); // 'value1'
$config->getOption('test3'); // 'new_value'
$config->getOption('test4'); // 'value4'
$newInstance->hasOption('test4'); // false

//discard
$config = $config->discard('test1', 'test3');
$config->hasOption('test1'); // false
$config->hasOption('test3'); // false
$config->hasOption('test4'); // true

//push & pop
$config = new ConfigurationContainer();
$config->setOption('list', 'item1');
$config = $config->push('list', 'item2', 'item3');
$config->getOption('list'); // ['item1', 'item2', 'item3']
$value = $config->pop('list'); // 'item3'

//preserve instance
$config = new ConfigurationContainer();
$config->preserveInstance = true;
$config->setOption('test1', 'val1');
$newConf = $config->option('test2', 'val2');
$config->hasOption('test1'); // true
$config->hasOption('test2'); // true
$newConf->getOption('test2') == $config->getOption('test2'); // true

br/, (*10)

License

Released under the MIT license., (*11)

The Versions

23/02 2015

dev-master

9999999-dev

A fluent configuration trait for PHP

  Sources   Download

MIT License

The Requires

  • php >=5.4.0

 

by Emmanuel Antico

php configuration trait fluent

23/02 2015

1.2

1.2.0.0

A fluent configuration trait for PHP

  Sources   Download

MIT License

The Requires

  • php >=5.4.0

 

by Emmanuel Antico

php configuration trait fluent

15/11 2014

1.1

1.1.0.0

A fluent configuration trait for PHP

  Sources   Download

MIT License

The Requires

  • php >=5.4.0

 

by Emmanuel Antico

php configuration trait fluent

22/10 2014

1.0.0

1.0.0.0

A fluent configuration trait for PHP

  Sources   Download

MIT License

The Requires

  • php >=5.4.0

 

by Emmanuel Antico

php configuration trait fluent