Skip to content

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

License

Notifications You must be signed in to change notification settings

the-kbA-team/memory-container

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages