inpsyde/config-interface

Standard interface for configuration container

1.0.0 2018-11-23 10:54 UTC

This package is auto-updated.

Last update: 2021-12-23 22:46:46 UTC


README

The package provides a standard interface for a common configuration value container. inpsyde/config provides a flexible, WordPress aware and thorough implementation of this interface.

Why

When it comes to more complex plugins you want to have a reliable and uniform way to access your configuration. Instead of coupling your business logic to details about configuration you can depend on an abstract configuration interface.

The Config interface

<?php

namespace Inpsyde\Config;

use Inpsyde\Config\Exception\Exception;

interface Config
{
    /**
     * @throws Exception
     * @return mixed
     */
    public function get(string $key);

    public function has(string $key) : bool;
}

This interface reminds of PSR-11 and we considered to extend or simply use PSR-11 as interface but the documentation says that it is explicitly meant as common interface for dependency injection containers.

Also mixing up DI-Containers with config containers is not a good thing as both targeting different purposes.

License

Copyright (c) 2018 David Naber, Inpsyde GmbH

Good news, this plugin is free for everyone! Since it's released under the MIT License you can use it free of charge on your personal or commercial website.

Contributing

All feedback, bug reports and pull requests are welcome.