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
SessionChangeMessageArray
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
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 add
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getIterator
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 asArray
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/** @noinspection PhpUnhandledExceptionInspection */
4// TODO unit-test
5
6class SessionChangeMessageArray implements IteratorAggregate {
7
8    protected $array = [];
9
10    public function __construct(SessionChangeMessage... $messages) {
11
12        $this->array = $messages;
13    }
14
15
16    public function add(SessionChangeMessage $message) {
17
18        $this->array[] = $message;
19    }
20
21
22    public function getIterator(): Iterator {
23
24        return new ArrayIterator($this->array);
25    }
26
27
28    public function asArray() : array {
29
30        return $this->array;
31    }
32}