ListScreenCollection.php
1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
namespace AC;
use Countable;
use Iterator;
final class ListScreenCollection implements Iterator, Countable {
/**
* @var ListScreen[]
*/
private $data = [];
public function __construct( array $list_screens = [] ) {
array_map( [ $this, 'add' ], $list_screens );
}
public function add( ListScreen $list_screen ) {
$this->data[ $list_screen->get_layout_id() ] = $list_screen;
}
public function remove( ListScreen $list_screen ) {
unset( $this->data[ $list_screen->get_layout_id() ] );
}
#[\ReturnTypeWillChange]
public function rewind() {
reset( $this->data );
}
/**
* @return ListScreen
*/
#[\ReturnTypeWillChange]
public function current() {
return current( $this->data );
}
public function get_first() {
return reset( $this->data );
}
#[\ReturnTypeWillChange]
public function key() {
return key( $this->data );
}
#[\ReturnTypeWillChange]
public function next() {
return next( $this->data );
}
#[\ReturnTypeWillChange]
public function valid() {
$key = $this->key();
return ( $key !== null && $key !== false );
}
/**
* @return int
*/
#[\ReturnTypeWillChange]
public function count() {
return count( $this->data );
}
/**
* @param ListScreen $list_screen
*
* @return bool
*/
public function contains( ListScreen $list_screen ) {
return isset( $this->data[ $list_screen->get_layout_id() ] );
}
public function get_copy(): array {
$copy = $this->data;
reset( $copy );
return $copy;
}
}