minime/quantum

This package is abandoned and no longer maintained. No replacement package was suggested.

Quantum is unique kind of container made to manage parallel states of data structures.

0.0.1 2013-12-06 16:41 UTC

This package is auto-updated.

Last update: 2022-02-01 12:29:05 UTC


README

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