Quantum is unique kind of container made to manage parallel states of data structures
PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/Minime/Quantum
test/suite/Minime/Quantum
.gitignore
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml.dist

README.md

Minime \ Quantum

Build Status Coverage Status Scrutinizer Quality Score SensioLabsInsight

Quantum is unique kind of container made to manage parallel states of data structures. Give it a callable factory and start unfolding.

Installation

Friends of terminal: composer require minime/quantum:~0.0 🎱

Usage

<?php

// Quantum Object looks more expressive when aliased
use Minime\Quantum\Object as Container;

// Quantum needs a callable to produce new states, so let's create one
$Container = (new Container(function(){ return new SomeFancyContainer(); }))

// this is the default environment
->mount('default')->interact(function($container){
    $container->shared('Database', new Database(
        [
            'driver' => 'postgre',
            'host' => 'localhost'
        ]
    ));
    /*...*/
})

// this will be our test/cli environment
->extend('default', 'test')->interact(function($container){
    $container->get('Database')->config(
        [
            'database' => 'app_unit_test',
            'user' => 'foo',
            'password' => 'bar'
        ]
    );
})

// this will be our development environment
->extend('default', 'development')->interact(function($container){
    $container->get('Database')->config(
        [
            'database' => 'app_development',
            'user' => 'bar',
            'password' => 'baz'
        ]
    );
})


// production!
->extend('default', 'production')->interact(function($container){
    $container->get('Database')->config(
        [
            'host' => 'my.production.ip',
            'database' => 'app',
            'user' => 'app',
            'password' => 'P@sW04d'
        ]
    );
});

Switching between states:

<?php

// get test container
$TestContainer  = $Container->mount('test')->expose();

// get development container
$DevelopmentContainer = $Container->mount('development')->expose();

// get production container
$ProductionContainer = $Container->mount('production')->expose();

Interact with all states at once:

<?php

$Container->each(function($container){
    // routine
});

Copyright

Copyright (c) 2013 Márcio Almada. Distributed under the terms of an MIT-style license. See LICENSE for details.

Bitdeli Badge