MDL-54934 workshop: ensure "Current phase" is always separated
[moodle.git] / lib / lessphp / Configurable.php
blobbe81c9f5f3d39bbab9915524f1989612d432dbcf
1 <?php
3 /**
4 * Configurable
6 * @package Less
7 * @subpackage Core
8 */
9 abstract class Less_Configurable {
11 /**
12 * Array of options
14 * @var array
16 protected $options = array();
18 /**
19 * Array of default options
21 * @var array
23 protected $defaultOptions = array();
26 /**
27 * Set options
29 * If $options is an object it will be converted into an array by called
30 * it's toArray method.
32 * @throws Exception
33 * @param array|object $options
36 public function setOptions($options){
37 $options = array_intersect_key($options,$this->defaultOptions);
38 $this->options = array_merge($this->defaultOptions, $this->options, $options);
42 /**
43 * Get an option value by name
45 * If the option is empty or not set a NULL value will be returned.
47 * @param string $name
48 * @param mixed $default Default value if confiuration of $name is not present
49 * @return mixed
51 public function getOption($name, $default = null){
52 if(isset($this->options[$name])){
53 return $this->options[$name];
55 return $default;
59 /**
60 * Set an option
62 * @param string $name
63 * @param mixed $value
65 public function setOption($name, $value){
66 $this->options[$name] = $value;