Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
75.00% covered (warning)
75.00%
3 / 4
75.00% covered (warning)
75.00%
3 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
MobileCollection
75.00% covered (warning)
75.00%
3 / 4
75.00% covered (warning)
75.00%
3 / 4
4.25
0.00% covered (danger)
0.00%
0 / 1
 count
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isEmpty
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 add
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getIterator
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MobileFrontend\Models;
4
5use ArrayIterator;
6use Countable;
7use IteratorAggregate;
8use MediaWiki\Libs\Emptiable;
9
10/**
11 * A collection of pages, which are represented by the MobilePage class.
12 */
13class 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}