Skip to content

Configurable traits to add default config and setters and getters.

License

Notifications You must be signed in to change notification settings

originphp/configurable

Repository files navigation

Configurable

license build coverage

Configurable traits to add default config and setters and getters.

Installation

To install this package

$ composer require originphp/configurable

Usage

Both instance and static traits are available.

Set defaultConfig property

use Origin\Configurable\InstanceConfigurable as Configurable;

class MyObject
{
    use Configurable;

    protected $defaultConfig = [
        'foo' => 'bar'
    ];
}

To get a value from the config:

 $value = $this->config('foo'); // bar

To all of the values from the config

 $array = $this->config();

To set a value in the config:

 $this->config('foo','bar');
 $this->config(['foo'=>'bar']);

To set multiple values (merges config)

 $this->config(['foo'=>'bar']);

About

Configurable traits to add default config and setters and getters.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages