1<?php
2/**
3 * Copyright 2014-2016 Horde LLC (http://www.horde.org/)
4 *
5 * See the enclosed file COPYING 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-2016 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-2016 Horde LLC
21 * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
22 * @package   Stream
23 * @since     1.6.0
24 */
25class 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}
50