Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
4.35% |
1 / 23 |
|
20.00% |
1 / 5 |
CRAP | |
0.00% |
0 / 1 |
| core_kernel_classes_ContainerCollection | |
4.35% |
1 / 23 |
|
20.00% |
1 / 5 |
64.01 | |
0.00% |
0 / 1 |
| add | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| union | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| intersect | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| indexOf | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |||
| __toString | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg |
| 19 | * (under the project TAO & TAO2); |
| 20 | * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung |
| 21 | * (under the project TAO-TRANSFER); |
| 22 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 23 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | /** |
| 28 | * should inherit from standard collection provided in php |
| 29 | * |
| 30 | * @access public |
| 31 | * @author patrick.plichart@tudor.lu |
| 32 | * @package generis |
| 33 | |
| 34 | */ |
| 35 | class core_kernel_classes_ContainerCollection extends common_Collection |
| 36 | { |
| 37 | // --- ASSOCIATIONS --- |
| 38 | // generateAssociationEnd : |
| 39 | |
| 40 | // --- ATTRIBUTES --- |
| 41 | |
| 42 | // --- OPERATIONS --- |
| 43 | |
| 44 | /** |
| 45 | * Short description of method add |
| 46 | * |
| 47 | * @access public |
| 48 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 49 | * @param Object element |
| 50 | * @return void |
| 51 | */ |
| 52 | public function add(common_Object $element) |
| 53 | { |
| 54 | |
| 55 | parent::add($element); |
| 56 | } |
| 57 | |
| 58 | |
| 59 | /** |
| 60 | * Short description of method union |
| 61 | * |
| 62 | * @access public |
| 63 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 64 | * @param Collection collection |
| 65 | * @return core_kernel_classes_ContainerCollection |
| 66 | */ |
| 67 | public function union(common_Collection $collection) |
| 68 | { |
| 69 | $returnValue = null; |
| 70 | |
| 71 | |
| 72 | $returnValue = new core_kernel_classes_ContainerCollection($this); |
| 73 | $returnValue->sequence = array_merge($this->sequence, $collection->sequence); |
| 74 | |
| 75 | |
| 76 | return $returnValue; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Short description of method intersect |
| 81 | * |
| 82 | * @access public |
| 83 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 84 | * @param Collection collection |
| 85 | * @return core_kernel_classes_ContainerCollection |
| 86 | */ |
| 87 | public function intersect(common_Collection $collection) |
| 88 | { |
| 89 | $returnValue = null; |
| 90 | |
| 91 | |
| 92 | $returnValue = new core_kernel_classes_ContainerCollection(new common_Object(__METHOD__)); |
| 93 | $returnValue->sequence = array_uintersect( |
| 94 | $this->sequence, |
| 95 | $collection->sequence, |
| 96 | 'core_kernel_classes_ContainerComparator::compare' |
| 97 | ); |
| 98 | |
| 99 | |
| 100 | return $returnValue; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Short description of method indexOf |
| 105 | * |
| 106 | * @access public |
| 107 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 108 | * @param Object resource |
| 109 | * @return Integer |
| 110 | */ |
| 111 | public function indexOf(common_Object $resource) |
| 112 | { |
| 113 | $returnValue = null; |
| 114 | |
| 115 | |
| 116 | $returnValue = -1; |
| 117 | foreach ($this->sequence as $index => $_resource) { |
| 118 | if ($_resource instanceof core_kernel_classes_Resource) { |
| 119 | if ($resource->equals($_resource)) { |
| 120 | return $index; |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | |
| 126 | return $returnValue; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Short description of method __toString |
| 131 | * |
| 132 | * @access public |
| 133 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 134 | * @return string |
| 135 | */ |
| 136 | public function __toString() |
| 137 | { |
| 138 | $returnValue = (string) ''; |
| 139 | |
| 140 | |
| 141 | $returnValue = 'Collection containning ' . $this->count() . ' elements' ; |
| 142 | |
| 143 | |
| 144 | return (string) $returnValue; |
| 145 | } |
| 146 | } |