[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/lessphp/ -> Configurable.php (source)

   1  <?php
   2  
   3  /**

   4   * Configurable

   5   *

   6   * @package Less

   7   * @subpackage Core

   8   */
   9  abstract class Less_Configurable {
  10  
  11      /**

  12       * Array of options

  13       *

  14       * @var array

  15       */
  16      protected $options = array();
  17  
  18      /**

  19       * Array of default options

  20       *

  21       * @var array

  22       */
  23      protected $defaultOptions = array();
  24  
  25  
  26      /**

  27       * Set options

  28       *

  29       * If $options is an object it will be converted into an array by called

  30       * it's toArray method.

  31       *

  32       * @throws Exception

  33       * @param array|object $options

  34       *

  35       */
  36  	public function setOptions($options){
  37          $options = array_intersect_key($options,$this->defaultOptions);
  38          $this->options = array_merge($this->defaultOptions, $this->options, $options);
  39      }
  40  
  41  
  42      /**

  43       * Get an option value by name

  44       *

  45       * If the option is empty or not set a NULL value will be returned.

  46       *

  47       * @param string $name

  48       * @param mixed $default Default value if confiuration of $name is not present

  49       * @return mixed

  50       */
  51  	public function getOption($name, $default = null){
  52          if(isset($this->options[$name])){
  53              return $this->options[$name];
  54          }
  55          return $default;
  56      }
  57  
  58  
  59      /**

  60       * Set an option

  61       *

  62       * @param string $name

  63       * @param mixed $value

  64       */
  65  	public function setOption($name, $value){
  66          $this->options[$name] = $value;
  67      }
  68  
  69  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1