Skip to content

Commit

Permalink
[mms] Added the 'max' and 'min' properties to Horde_Imap_Client_Ids.
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed May 14, 2014
1 parent d07ff6d commit f6579b3
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 9 deletions.
11 changes: 11 additions & 0 deletions framework/Imap_Client/doc/Horde/Imap/Client/UPGRADING
Expand Up @@ -11,6 +11,17 @@
This lists the API changes between releases of the package.


Upgrading to 2.20.0
===================

- Horde_Imap_Client_Ids

- min
- max

These properties have been added.


Upgrading to 2.19.0
===================

Expand Down
15 changes: 12 additions & 3 deletions framework/Imap_Client/lib/Horde/Imap/Client/Ids.php
Expand Up @@ -23,6 +23,8 @@
* @property-read boolean $all Does this represent an ALL message set?
* @property-read array $ids The list of IDs.
* @property-read boolean $largest Does this represent the largest ID in use?
* @property-read string $max The largest ID (@since 2.20.0).
* @property-read string $min The smallest ID (@since 2.20.0).
* @property-read string $range_string Generates a range string consisting of
* all messages between begin and end of
* ID list.
Expand Down Expand Up @@ -101,14 +103,21 @@ public function __get($name)
case 'largest':
return ($this->_ids === self::LARGEST);

case 'max':
$this->sort();
return end($this->_ids);

case 'min':
$this->sort();
return reset($this->_ids);

case 'range_string':
if (!count($this)) {
return '';
}

$this->sort();
$min = reset($this->_ids);
$max = end($this->_ids);
$min = $this->min;
$max = $this->max;

return ($min == $max)
? $min
Expand Down
12 changes: 6 additions & 6 deletions framework/Imap_Client/package.xml
Expand Up @@ -12,16 +12,16 @@
</lead>
<date>2014-05-14</date>
<version>
<release>2.19.7</release>
<api>2.19.0</api>
<release>2.20.0</release>
<api>2.20.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Added the &apos;max&apos; and &apos;min&apos; properties to Horde_Imap_Client_Ids.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -2401,15 +2401,15 @@
</release>
<release>
<version>
<release>2.19.7</release>
<api>2.19.0</api></version>
<release>2.20.0</release>
<api>2.20.0</api></version>
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2014-05-13</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Added the &apos;max&apos; and &apos;min&apos; properties to Horde_Imap_Client_Ids.
</notes>
</release>
</changelog>
Expand Down
36 changes: 36 additions & 0 deletions framework/Imap_Client/test/Horde/Imap/Client/IdsTest.php
Expand Up @@ -311,4 +311,40 @@ public function testRemove()
);
}

public function testMinAndMax()
{
$ids = new Horde_Imap_Client_Ids(array(1));

$this->assertEquals(
1,
$ids->min
);
$this->assertEquals(
1,
$ids->max
);

$ids2 = new Horde_Imap_Client_Ids(array(1, 2));

$this->assertEquals(
1,
$ids2->min
);
$this->assertEquals(
2,
$ids2->max
);

$ids3 = new Horde_Imap_Client_Ids(array(1, 5, 3));

$this->assertEquals(
1,
$ids3->min
);
$this->assertEquals(
5,
$ids3->max
);
}

}

0 comments on commit f6579b3

Please sign in to comment.