PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.26
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.26
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
fluent-cart / vendor / openspout / openspout / src / Common / Manager / OptionsManagerAbstract.php

OptionsManagerAbstract.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.3.26, at vendor/openspout/openspout/src/Common/Manager/OptionsManagerAbstract.php

73 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\OpenSpout\Common\Manager;
4
5 abstract class OptionsManagerAbstract implements OptionsManagerInterface
6 {
7 public const PREFIX_OPTION = 'OPTION_';
8 /** @var string[] List of all supported option names */
9 private $supportedOptions = [];
10 /** @var array Associative array [OPTION_NAME => OPTION_VALUE] */
11 private $options = [];
12 /**
13 * OptionsManagerAbstract constructor.
14 */
15 public function __construct()
16 {
17 $this->supportedOptions = $this->getSupportedOptions();
18 $this->setDefaultOptions();
19 }
20 /**
21 * Sets the given option, if this option is supported.
22 *
23 * @param string $optionName
24 * @param mixed $optionValue
25 */
26 public function setOption($optionName, $optionValue)
27 {
28 if (\in_array($optionName, $this->supportedOptions, \true)) {
29 $this->options[$optionName] = $optionValue;
30 }
31 }
32 /**
33 * Add an option to the internal list of options
34 * Used only for mergeCells() for now.
35 *
36 * @param mixed $optionName
37 * @param mixed $optionValue
38 */
39 public function addOption($optionName, $optionValue)
40 {
41 if (\in_array($optionName, $this->supportedOptions, \true)) {
42 if (!isset($this->options[$optionName])) {
43 $this->options[$optionName] = [];
44 } elseif (!\is_array($this->options[$optionName])) {
45 $this->options[$optionName] = [$this->options[$optionName]];
46 }
47 $this->options[$optionName][] = $optionValue;
48 }
49 }
50 /**
51 * @param string $optionName
52 *
53 * @return null|mixed The set option or NULL if no option with given name found
54 */
55 public function getOption($optionName)
56 {
57 $optionValue = null;
58 if (isset($this->options[$optionName])) {
59 $optionValue = $this->options[$optionName];
60 }
61 return $optionValue;
62 }
63 /**
64 * @return array List of supported options
65 */
66 protected abstract function getSupportedOptions();
67 /**
68 * Sets the default options.
69 * To be overriden by child classes.
70 */
71 protected abstract function setDefaultOptions();
72 }
73