Move OptionManager from Common/Manager to Manager (#428)
This commit is contained in:
1 parent
bc17311f5f
commit
69b091b37c
13 files changed
+23
-20
No files matched your search
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer\Common\Manager;
|
||||
|
||||
/**
|
||||
* Class OptionsManager
|
||||
* Writer' options manager
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Manager
|
||||
*/
|
||||
abstract class OptionsManager implements OptionsManagerInterface
|
||||
{
|
||||
const PREFIX_OPTION = 'OPTION_';
|
||||
|
||||
/** @var string[] List of all supported option names */
|
||||
private $supportedOptions = [];
|
||||
|
||||
/** @var array Associative array [OPTION_NAME => OPTION_VALUE] */
|
||||
private $options = [];
|
||||
|
||||
/**
|
||||
* WriterOptions constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->supportedOptions = $this->getSupportedOptions();
|
||||
$this->setDefaultOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array List of supported options
|
||||
*/
|
||||
abstract protected function getSupportedOptions();
|
||||
|
||||
/**
|
||||
* Sets the default options.
|
||||
* To be overriden by child classes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function setDefaultOptions();
|
||||
|
||||
/**
|
||||
* Sets the given option, if this option is supported.
|
||||
*
|
||||
* @param string $optionName
|
||||
* @param mixed $optionValue
|
||||
* @return void
|
||||
*/
|
||||
public function setOption($optionName, $optionValue)
|
||||
{
|
||||
if (in_array($optionName, $this->supportedOptions)) {
|
||||
$this->options[$optionName] = $optionValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @return mixed|null The set option or NULL if no option with given name found
|
||||
*/
|
||||
public function getOption($optionName)
|
||||
{
|
||||
$optionValue = null;
|
||||
|
||||
if (isset($this->options[$optionName])) {
|
||||
$optionValue = $this->options[$optionName];
|
||||
}
|
||||
|
||||
return $optionValue;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer\Common\Manager;
|
||||
|
||||
/**
|
||||
* Interface OptionsManagerInterface
|
||||
* Writer' options interface
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Manager
|
||||
*/
|
||||
interface OptionsManagerInterface
|
||||
{
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @param mixed $optionValue
|
||||
* @return void
|
||||
*/
|
||||
public function setOption($optionName, $optionValue);
|
||||
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @return mixed|null The set option or NULL if no option with given name found
|
||||
*/
|
||||
public function getOption($optionName);
|
||||
}
|
||||
Reference in new issue
Block a user