Skip to content

Latest commit

 

History

History
61 lines (46 loc) · 1.61 KB

README.md

File metadata and controls

61 lines (46 loc) · 1.61 KB

Memory container

License: MIT PHP Version Maintainability Test Coverage

PSR-11 container storing its values in memory and offering a singleton access.

Usage

A simple example:

<?php
namespace vendor\product;

class Greeter
{
    public function __construct(\Closure $logic) {
        printf('%s%s', $logic('world'), PHP_EOL);
    }
}
<?php

use kbATeam\MemoryContainer\Container;
use vendor\product\Greeter;

Container::singleton()->add('hello', function ($what) {
    return sprintf('Hello %s!', $what);
});
// ...
$example = new Greeter(Container::singleton()->get('hello'));

Testing

Get composer, and install the dependencies.

composer install

Call phpunit to run the tests available.

vendor/bin/phpunit