vendor/tedivm/stash/src/Stash/Driver/AbstractDriver.php line 39

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Stash package.
  4.  *
  5.  * (c) Robert Hafner <tedivm@tedivm.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Stash\Driver;
  11. use Stash\Interfaces\DriverInterface;
  12. use Stash\Exception\RuntimeException;
  13. /**
  14.  * Abstract base class for all drivers to use.
  15.  *
  16.  * @package Stash
  17.  * @author  Robert Hafner <tedivm@tedivm.com>
  18.  */
  19. abstract class AbstractDriver implements DriverInterface
  20. {
  21.     /**
  22.      * Initializes the driver.
  23.      *
  24.      * @param array $options
  25.      *   An additional array of options to pass through to setOptions().
  26.      *
  27.      * @throws RuntimeException
  28.      */
  29.     public function __construct(array $options = array())
  30.     {
  31.         if (!static::isAvailable()) {
  32.             throw new RuntimeException(get_class($this) . ' is not available.');
  33.         }
  34.         $this->setOptions($options);
  35.     }
  36.     /**
  37.      * @return array
  38.      */
  39.     public function getDefaultOptions()
  40.     {
  41.         return array();
  42.     }
  43.     /**
  44.      * {@inheritdoc}
  45.      */
  46.     protected function setOptions(array $options = array())
  47.     {
  48.         // empty
  49.     }
  50.     /**
  51.      * {@inheritdoc}
  52.      */
  53.     public static function isAvailable()
  54.     {
  55.         return true;
  56.     }
  57.     /**
  58.      * {@inheritdoc}
  59.      */
  60.     public function isPersistent()
  61.     {
  62.         return false;
  63.     }
  64. }