aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/lib/SabreDAV/vendor/oldsabre/vobject/lib/Sabre/VObject/ElementList.php
blob: 317d7849ca1b5e8c70e5d994c20b0035f7daf75f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php

namespace OldSabre\VObject;

/**
 * VObject ElementList
 *
 * This class represents a list of elements. Lists are the result of queries,
 * such as doing $vcalendar->vevent where there's multiple VEVENT objects.
 *
 * @copyright Copyright (C) 2007-2013 fruux GmbH (https://fruux.com/).
 * @author Evert Pot (http://evertpot.com/)
 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
 */
class ElementList implements \Iterator, \Countable, \ArrayAccess {

    /**
     * Inner elements
     *
     * @var array
     */
    protected $elements = array();

    /**
     * Creates the element list.
     *
     * @param array $elements
     */
    public function __construct(array $elements) {

        $this->elements = $elements;

    }

    /* {{{ Iterator interface */

    /**
     * Current position
     *
     * @var int
     */
    private $key = 0;

    /**
     * Returns current item in iteration
     *
     * @return Element
     */
    public function current() {

        return $this->elements[$this->key];

    }

    /**
     * To the next item in the iterator
     *
     * @return void
     */
    public function next() {

        $this->key++;

    }

    /**
     * Returns the current iterator key
     *
     * @return int
     */
    public function key() {

        return $this->key;

    }

    /**
     * Returns true if the current position in the iterator is a valid one
     *
     * @return bool
     */
    public function valid() {

        return isset($this->elements[$this->key]);

    }

    /**
     * Rewinds the iterator
     *
     * @return void
     */
    public function rewind() {

        $this->key = 0;

    }

    /* }}} */

    /* {{{ Countable interface */

    /**
     * Returns the number of elements
     *
     * @return int
     */
    public function count() {

        return count($this->elements);

    }

    /* }}} */

    /* {{{ ArrayAccess Interface */


    /**
     * Checks if an item exists through ArrayAccess.
     *
     * @param int $offset
     * @return bool
     */
    public function offsetExists($offset) {

        return isset($this->elements[$offset]);

    }

    /**
     * Gets an item through ArrayAccess.
     *
     * @param int $offset
     * @return mixed
     */
    public function offsetGet($offset) {

        return $this->elements[$offset];

    }

    /**
     * Sets an item through ArrayAccess.
     *
     * @param int $offset
     * @param mixed $value
     * @return void
     */
    public function offsetSet($offset,$value) {

        throw new \LogicException('You can not add new objects to an ElementList');

    }

    /**
     * Sets an item through ArrayAccess.
     *
     * This method just forwards the request to the inner iterator
     *
     * @param int $offset
     * @return void
     */
    public function offsetUnset($offset) {

        throw new \LogicException('You can not remove objects from an ElementList');

    }

    /* }}} */

}

© 2014-2024 Faster IT GmbH | imprint | privacy policy