http://phing.info/

Source Code Coverage

Designed for use with PHPUnit2, Xdebug and Phing.

Methods: 2 LOC: 65 Statements: 6

Source file Statements Methods Total coverage
Set.php 100.0% 100.0% 100.0%
 
1
<?php
2
/**
3
 * Xyster Framework
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the new BSD license that is bundled
8
 * with this package in the file LICENSE.txt.
9
 * It is also available through the world-wide-web at this URL:
10
 * http://www.opensource.org/licenses/bsd-license.php
11
 * If you did not receive a copy of the license and are unable to
12
 * obtain it through the world-wide-web, please send an email
13
 * to xyster@devweblog.org so we can send you a copy immediately.
14
 *
15
 * @category  Xyster
16
 * @package   Xyster_Collection
17
 * @copyright Copyright (c) 2007 Irrational Logic (http://devweblog.org)
18
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
19
 */
20
/**
21
 * @see Xyster_Collection
22
 */
23 1
require_once 'Xyster/Collection.php';
24
/**
25
 * @see Xyster_Collection_Set_Interface
26
 */
27 1
require_once 'Xyster/Collection/Set/Interface.php';
28
/**
29
 * Simple implementation of the no-duplicate collection
30
 *
31
 * @category  Xyster
32
 * @package   Xyster_Collection
33
 * @copyright Copyright (c) 2007 Irrational Logic (http://devweblog.org)
34
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
35
 */
36
class Xyster_Collection_Set extends Xyster_Collection implements Xyster_Collection_Set_Interface
37
{
38
	/**
39
	 * Creates a new set
40
	 *
41
	 * @param Xyster_Collection_Interface $set The values to add to this set
42
	 * @param boolean $immutable Whether the set can be changed
43
	 */
44
	public function __construct( Xyster_Collection_Interface $c = null, $immutable = false )
45
	{
46 310
		parent::__construct($c, $immutable);
47
	}
48
49
	/**
50
	 * Adds an item to the set
51
	 *
52
	 * This collection doesn't accept duplicate values, and will return false
53
	 * if the provided value is already in the collection.
54
	 *
55
	 * @param mixed $item The item to add
56
	 * @return boolean Whether the set changed as a result of this method
57
	 * @throws Xyster_Collection_Exception if the collection cannot be modified
58
	 */
59
	public function add( $item )
60
	{
61 100
		if ( !$this->contains($item) ) {
62 100
			return parent::add($item);
63 1
		} return false;
64
	}
65
}


Report generated at 2007-10-08T19:32:24-05:00