PHP Trait Bluz\Common\Options

Example of usage class Foo { use \Bluz\Common\Options; protected $bar = ''; protected $baz = ''; public function setBar($value) { $this->bar = $value; } public function setBaz($value) { $this->baz = $value; } } $Foo = new Foo(['bar'=>123, 'baz'=>456]);
Show file Open project: bluzphp/framework

Protected Properties

Property Type Description
$options options store

Public Methods

Method Description
getOption ( string $key, string | null $section = null ) : mixed Get option by key
getOptions ( ) : array Get all options
setOption ( string $key, string $value ) : void Set option by key over setter
setOptions ( array $options ) : self Setup, check and init options

Protected Methods

Method Description
initOptions ( ) : void Check and initialize options in package

Private Methods

Method Description
normalizeKey ( string $key ) : string Normalize key name

Method Details

getOption() public method

Get option by key
public getOption ( string $key, string | null $section = null ) : mixed
$key string
$section string | null
return mixed

getOptions() public method

Get all options
public getOptions ( ) : array
return array

initOptions() protected method

Check and initialize options in package
protected initOptions ( ) : void
return void

setOption() public method

Set option by key over setter
public setOption ( string $key, string $value ) : void
$key string
$value string
return void

setOptions() public method

Requirements - options must be a array - options can be null
public setOptions ( array $options ) : self
$options array
return self

Property Details

$options protected property

options store
protected $options