[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/horde/framework/Horde/Support/ -> ObjectStub.php (source)

   1  <?php
   2  /**
   3   * Provides a wrapper around an object to return null for non-existent
   4   * properties (instead of throwing an error).
   5   *
   6   * Copyright 2012-2014 Horde LLC (http://www.horde.org/)
   7   *
   8   * @author   Michael Slusarz <slusarz@horde.org>
   9   * @category Horde
  10   * @license  http://www.horde.org/licenses/bsd BSD
  11   * @package  Support
  12   */
  13  
  14  /**
  15   * @author   Michael Slusarz <slusarz@horde.org>
  16   * @category Horde
  17   * @license  http://www.horde.org/licenses/bsd BSD
  18   * @package  Support
  19   */
  20  class Horde_Support_ObjectStub
  21  {
  22      /**
  23       * Original data object.
  24       *
  25       * @var array
  26       */
  27      protected $_data;
  28  
  29      /**
  30       * Constructor
  31       *
  32       * @param object $data  The original data object.
  33       */
  34      public function __construct($data)
  35      {
  36          $this->_data = $data;
  37      }
  38  
  39      /**
  40       */
  41      public function __get($name)
  42      {
  43          return isset($this->_data->$name)
  44              ? $this->_data->$name
  45              : null;
  46      }
  47  
  48      /**
  49       */
  50      public function __set($name, $value)
  51      {
  52          $this->_data->$name = $value;
  53      }
  54  
  55      /**
  56       */
  57      public function __isset($name)
  58      {
  59          return isset($this->_data->$name);
  60      }
  61  
  62      /**
  63       */
  64      public function __unset($name)
  65      {
  66          unset($this->_data->$name);
  67      }
  68  
  69  }


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