2017 © Pedro Peláez
 

library parameterizer

Elao Parameterizer

image

elao/parameterizer

Elao Parameterizer

  • Thursday, July 3, 2014
  • by Elao
  • Repository
  • 16 Watchers
  • 0 Stars
  • 22 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

ElaoParameterizer

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Build Status Scrutinizer Code Quality Code Coverage, (*2)

Description:

This component provides a set of classes to handle some service parameters in a structured way, and a twig dat.GUI extension to set them with style., (*3)

A symfony ElaoParameterizerBundle also exists to simplify integration in your project., (*4)

Installation:

Add ElaoParameterizer in your composer.json:, (*5)

{
    "require": {
        "elao/elao/parameterizer": "1.0.*"
    }
}

Now tell composer to download the library by running the command:, (*6)

$ php composer.phar update elao/parameterizer

How to use it:

Classes are structured in a hierarchical manner, where a single Parameterizer contains n Patterns, each one containing n Parameters., (*7)

Parameterizer
    Pattern
        Parameter
        Parameter
        Parameter
    Pattern
        Parameter
        Parameter

All classes takes a name as argument, and Parameter an initial value., (*8)

A factory is provided to simplify the parameterizer creation, and each class provides a convenient method to simplify its children creation., (*9)

$factory = new ParameterizerFactory(new Inflector());

// Create a "foo" named parameterizer
$parameterizer = $factory->create('foo');

$parameterizer
    // Create a "foo" named pattern
    ->create('foo')
        // Create a "bar" named parameter with a "baz" value
        ->create('bar', 'baz')
        // Create a "dinosaur" named parameter with a 42 value
        ->create('dinosaur', 42);

Options

A pattern can takes an array of options. One of them is "label", which, if not provided, is automatically set as a human readable version of the pattern name, via an inflector., (*10)

$pattern->setOptions(array('foo' => 'bar'));

// bar
$pattern->getOption('foo');
// 123 (default value, as "bar" options does not exists)
$pattern->getOption('bar', 123);
// Label
$pattern->getOption('label');

A parameter can also takes an array of options. Same rule applies for the label, and some extra options, such as "choices", "min", "max" and "set", are specific for dat.GUI integration., (*11)

$parameter->setOptions(array('min' => 1, 'max' => 2));

// 1
$parameter->getOption('min');
// null (default value, as "step" options does not exists)
$parameter->getOption('step');
// Label
$parameter->getOption('label');

Values

At each level, you can get and merge values to communicate and synchronize with the real world., (*12)

// Gives a pattern indexed array of indexed parameter values array
$parameterizer->getValues();
// Merge
$parameterizer->mergeValues(array('foo' => array('bar' => 'baz')));

// Get indexed parameter values array
$pattern->getValues();
// Merge
$pattern->mergeValues(array('bar' => 'baz'));
// Get foo parameter value
$pattern->getValue('bar');
// Set foo parameter value
$pattern->setValue('bar', 'baz');

// Get value
$parameter->getValue();
// Set value
$parameter->setValue();

Interface

An Parameterizable interface is provided to harmonize your code., (*13)

dat.GUI twig extension

This extension provides a elao_parameterizer_dat_gui_render_javascript method, which render the javascript part of dat.GUI integration. It accepting an array of options, one of them, "gui" being a string of the name of the dat.GUI instance to use., (*14)

<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.5/dat.gui.min.js"></script>
<script>
    var gui = new dat.GUI();
    {{ elao_parameterizer_dat_gui_render_javascript({'gui': 'gui'}) }}
</script>

The Versions

03/07 2014

dev-master

9999999-dev https://github.com/Elao/ElaoParameterizer

Elao Parameterizer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

elao parameterizer

02/07 2014

1.0.1

1.0.1.0 https://github.com/Elao/ElaoParameterizer

Elao Parameterizer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

elao parameterizer

02/07 2014

1.0.0

1.0.0.0 https://github.com/Elao/ElaoParameterizer

Elao Parameterizer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

elao parameterizer