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     */
25    public function count(): int {
26        return count( $this->pages );
27    }
28
29    /**
30     * Return size of the collection
31     * @return bool
32     */
33    public function isEmpty() {
34        return !$this->pages;
35    }
36
37    /**
38     * Adds a page to the collection.
39     *
40     * @param MobilePage $page Page to add
41     */
42    public function add( MobilePage $page ) {
43        $this->pages[] = $page;
44    }
45
46    public function getIterator(): ArrayIterator {
47        return new ArrayIterator( $this->pages );
48    }
49}