mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
83 lines
1.4 KiB
PHP
83 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Orange Management
|
|
*
|
|
* PHP Version 7.1
|
|
*
|
|
* @category TBD
|
|
* @package TBD
|
|
* @author OMS Development Team <dev@oms.com>
|
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link http://orange-management.com
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace phpOMS\Config;
|
|
|
|
/**
|
|
* Options trait.
|
|
*
|
|
* @category Framework
|
|
* @package phpOMS\Config
|
|
* @since 1.0.0
|
|
*/
|
|
trait OptionsTrait
|
|
{
|
|
|
|
/**
|
|
* Options.
|
|
*
|
|
* @var array
|
|
* @since 1.0.0
|
|
*/
|
|
private $options = [];
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function exists($key) : bool
|
|
{
|
|
return isset($this->options[$key]);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getOption($key)
|
|
{
|
|
return $this->options[$key] ?? null;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function setOption($key, $value, bool $overwrite = true) : bool
|
|
{
|
|
if ($overwrite || !array_key_exists($key, $this->options)) {
|
|
$this->options[$key] = $value;
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function setOptions(array $pair, bool $overwrite = true) : bool
|
|
{
|
|
if ($overwrite) {
|
|
$this->options += $pair;
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
}
|