Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
   1  <?php
   2  /**
   3   * Copyright 2014-2017 Horde LLC (http://www.horde.org/)
   4   *
   5   * See the enclosed file LICENSE for license information (LGPL). If you
   6   * did not receive this file, see http://www.horde.org/licenses/lgpl21.
   7   *
   8   * @category  Horde
   9   * @copyright 2014-2017 Horde LLC
  10   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  11   * @package   Stream
  12   */
  13  
  14  /**
  15   * Implementation of Horde_Stream that uses a PHP native string variable
  16   * for the internal storage.
  17   *
  18   * @author    Michael Slusarz <slusarz@horde.org>
  19   * @category  Horde
  20   * @copyright 2014-2017 Horde LLC
  21   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  22   * @package   Stream
  23   * @since     1.6.0
  24   */
  25  class Horde_Stream_String extends Horde_Stream
  26  {
  27      /**
  28       * Constructor.
  29       *
  30       * @param array $opts  Additional configuration options:
  31       * <pre>
  32       *   - string: (string) [REQUIRED] The PHP string.
  33       * </pre>
  34       *
  35       * @throws InvalidArgumentException
  36       */
  37      public function __construct(array $opts = array())
  38      {
  39          if (!isset($opts['string']) || !is_string($opts['string'])) {
  40              throw new InvalidArgumentException('Need a PHP string.');
  41          }
  42  
  43          $this->stream = Horde_Stream_Wrapper_String::getStream($opts['string']);
  44          unset($opts['string']);
  45  
  46          parent::__construct($opts);
  47      }
  48  
  49  }