FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
data-repository/src/MapperCollection.php at master · g4code/data-repository · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
g4code
/
data-repository
Public
Notifications
You must be signed in to change notification settings
Fork
5
Star
0
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
data-repository
/
src
/
MapperCollection.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
132 lines (115 loc) · 2.3 KB
Breadcrumbs
data-repository
/
src
/
MapperCollection.php
Copy path
File metadata and controls
132 lines (115 loc) · 2.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
namespace
G4
\
DataRepository
;
class
MapperCollection
implements
\Iterator, \Countable
{
/**
* @var int
*/
private
$
total
;
/**
* @var array
*/
private
$
keyMap
;
/**
* @var array
*/
private
$
rawData
;
/**
* @var int
*/
private
$
pointer
;
/**
* MapperCollection constructor.
* @param array $data
*/
public
function
__construct
(
array
$
data
)
{
$
this
->
keyMap
=
array_keys
(
$
data
);
$
this
->
rawData
=
$
data
;
$
this
->
pointer
=
0
;
}
/**
* Count elements of an object
* @return int The custom count as an integer.
*/
public
function
count
():
int
{
if
(
$
this
->
total
===
null
) {
$
this
->
total
=
count
(
$
this
->
rawData
);
}
return
$
this
->
total
;
}
/**
* @return mixed|null
*/
public
function
current
():
mixed
{
if
(
$
this
->
pointer
>=
$
this
->
count
()) {
return
null
;
}
if
(
$
this
->
hasCurrentRawData
()) {
return
$
this
->
currentRawData
();
}
}
/**
* Move forward to next element
*/
public
function
next
():
void
{
if
(
$
this
->
pointer
<
$
this
->
count
()) {
$
this
->
pointer
++;
}
}
/**
* Return the key of the current element
* @return int
*/
public
function
key
():
mixed
{
return
$
this
->
pointer
;
}
/**
* Checks if current position is valid
* @return bool
*/
public
function
valid
():
bool
{
return
$
this
->
current
() !==
null
;
}
/**
* Rewind the Iterator to the first element
* @return $this
*/
public
function
rewind
():
void
{
$
this
->
pointer
=
0
;
}
/**
* @return bool
*/
public
function
hasData
()
{
return
$
this
->
count
() >
0
;
}
/**
* @return array
*/
public
function
getRawData
()
{
return
$
this
->
rawData
;
}
/**
* @return bool
*/
private
function
hasCurrentRawData
()
{
return
isset
(
$
this
->
keyMap
[
$
this
->
pointer
]) &&
isset
(
$
this
->
rawData
[
$
this
->
keyMap
[
$
this
->
pointer
]]);
}
/**
* @return array
*/
private
function
currentRawData
()
{
return
$
this
->
rawData
[
$
this
->
keyMap
[
$
this
->
pointer
]];
}
}
Back
|
FazBrowse Home
|
New Git URL