Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
75.00% |
3 / 4 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
MobileCollection | |
75.00% |
3 / 4 |
|
75.00% |
3 / 4 |
4.25 | |
0.00% |
0 / 1 |
count | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isEmpty | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
add | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getIterator | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace MobileFrontend\Models; |
4 | |
5 | use ArrayIterator; |
6 | use Countable; |
7 | use IteratorAggregate; |
8 | use MediaWiki\Libs\Emptiable; |
9 | |
10 | /** |
11 | * A collection of pages, which are represented by the MobilePage class. |
12 | */ |
13 | class MobileCollection implements IteratorAggregate, Countable, Emptiable { |
14 | |
15 | /** |
16 | * The internal collection of pages. |
17 | * |
18 | * @var MobilePage[] |
19 | */ |
20 | protected $pages = []; |
21 | |
22 | /** |
23 | * Return size of the collection |
24 | * @return int |
25 | */ |
26 | public function count(): int { |
27 | return count( $this->pages ); |
28 | } |
29 | |
30 | /** |
31 | * Return size of the collection |
32 | * @return bool |
33 | */ |
34 | public function isEmpty() { |
35 | return !$this->pages; |
36 | } |
37 | |
38 | /** |
39 | * Adds a page to the collection. |
40 | * |
41 | * @param MobilePage $page Page to add |
42 | */ |
43 | public function add( MobilePage $page ) { |
44 | $this->pages[] = $page; |
45 | } |
46 | |
47 | /** |
48 | * @return ArrayIterator |
49 | */ |
50 | public function getIterator(): ArrayIterator { |
51 | return new ArrayIterator( $this->pages ); |
52 | } |
53 | } |