/usr/share/php/Horde/Imap/Client/Fetch/Results.php is in php-horde-imap-client 2.29.12-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 173 174 175 176 177 178 179 180 181 182 | <?php
/**
* Copyright 2012-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @copyright 2012-2016 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*/
/**
* Fetch results object for use with Horde_Imap_Client_Base#fetch().
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2012-2016 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*
* @property-read integer $key_type The key type (sequence or UID).
*/
class Horde_Imap_Client_Fetch_Results
implements ArrayAccess, Countable, IteratorAggregate
{
/**
* Key type constants.
*/
const SEQUENCE = 1;
const UID = 2;
/**
* Internal data array.
*
* @var array
*/
protected $_data = array();
/**
* Key type.
*
* @var integer
*/
protected $_keyType;
/**
* Class to use when creating a new fetch object.
*
* @var string
*/
protected $_obClass;
/**
* Constructor.
*
* @param string $ob_class Class to use when creating a new fetch
* object.
* @param integer $key_type Key type.
*/
public function __construct($ob_class = 'Horde_Imap_Client_Data_Fetch',
$key_type = self::UID)
{
$this->_obClass = $ob_class;
$this->_keyType = $key_type;
}
/**
*/
public function __get($name)
{
switch ($name) {
case 'key_type':
return $this->_keyType;
}
}
/**
* Return a fetch object, creating and storing an empty object in the
* results set if it doesn't currently exist.
*
* @param string $key The key to retrieve.
*
* @return Horde_Imap_Client_Data_Fetch The fetch object.
*/
public function get($key)
{
if (!isset($this->_data[$key])) {
$this->_data[$key] = new $this->_obClass();
}
return $this->_data[$key];
}
/**
* Return the list of IDs.
*
* @return array ID list.
*/
public function ids()
{
ksort($this->_data);
return array_keys($this->_data);
}
/**
* Return the first fetch object in the results, if there is only one
* object.
*
* @return null|Horde_Imap_Client_Data_Fetch The fetch object if there is
* only one object, or null.
*/
public function first()
{
return (count($this->_data) === 1)
? reset($this->_data)
: null;
}
/**
* Clears all fetch results.
*
* @since 2.6.0
*/
public function clear()
{
$this->_data = array();
}
/* ArrayAccess methods. */
/**
*/
public function offsetExists($offset)
{
return isset($this->_data[$offset]);
}
/**
*/
public function offsetGet($offset)
{
return isset($this->_data[$offset])
? $this->_data[$offset]
: null;
}
/**
*/
public function offsetSet($offset, $value)
{
$this->_data[$offset] = $value;
}
/**
*/
public function offsetUnset($offset)
{
unset($this->_data[$offset]);
}
/* Countable methods. */
/**
*/
public function count()
{
return count($this->_data);
}
/* IteratorAggregate methods. */
/**
*/
public function getIterator()
{
ksort($this->_data);
return new ArrayIterator($this->_data);
}
}
|