Debian Codegraph @

vendor/wikimedia/less.php/lib/Less/Configurable.php

raw
1 <?php
2 /**
3 * @private
4 */
5 abstract class Less_Configurable {
6
7 /**
8 * Array of options
9 *
10 * @var array
11 */
12 protected $options = [];
13
14 /**
15 * Array of default options
16 *
17 * @var array
18 */
19 protected $defaultOptions = [];
20
21 /**
22 * @param array $options
23 */
24 public function setOptions( $options ) {
25 $options = array_intersect_key( $options, $this->defaultOptions );
26 $this->options = array_merge( $this->defaultOptions, $this->options, $options );
27 }
28
29 /**
30 * Get an option value by name
31 *
32 * If the option is empty or not set a NULL value will be returned.
33 *
34 * @param string $name
35 * @param mixed $default Default value if confiuration of $name is not present
36 * @return mixed
37 */
38 public function getOption( $name, $default = null ) {
39 if ( isset( $this->options[$name] ) ) {
40 return $this->options[$name];
41 }
42 return $default;
43 }
44
45 /**
46 * Set an option
47 *
48 * @param string $name
49 * @param mixed $value
50 */
51 public function setOption( $name, $value ) {
52 $this->options[$name] = $value;
53 }
54
55 }