FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
data-repository/src/RepositoryCommand.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
/
RepositoryCommand.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
176 lines (151 loc) · 4.38 KB
Breadcrumbs
data-repository
/
src
/
RepositoryCommand.php
Copy path
File metadata and controls
176 lines (151 loc) · 4.38 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
namespace
G4
\
DataRepository
;
use
G4
\
DataRepository
\
Exception
\
MissingActionException
;
use
G4
\
DataRepository
\
Exception
\
MissingCustomCommandException
;
use
G4
\
DataRepository
\
Exception
\
MissingIdentityException
;
use
G4
\
DataRepository
\
Exception
\
MissingIdentityMapKeyException
;
use
G4
\
DataRepository
\
Exception
\
MissingMapperException
;
use
G4
\
DataRepository
\
Exception
\
MissingRussianDollKeyException
;
use
G4
\
DataMapper
\
Common
\
IdentityInterface
;
use
G4
\
DataMapper
\
Common
\
MappingInterface
;
class
RepositoryCommand
{
const
ACTION_UPSERT
=
'
upsert
'
;
const
ACTION_INSERT
=
'
insert
'
;
const
ACTION_DELETE
=
'
delete
'
;
const
ACTION_UPDATE
=
'
update
'
;
const
CUSTOM_COMMAND
=
'
custom_command
'
;
const
DELIMITER
=
'
|
'
;
/**
* @var MapperCollection
*/
private
$
map
;
private
$
russianDollKey
;
private
$
identityMapKey
;
private
$
customCommand
;
/**
* @var \G4\DataMapper\Common\IdentityInterface
*/
private
$
identity
;
private
$
action
;
/**
* @return MapperCollection
* @throws MissingMapperException
*/
public
function
getMap
()
{
if
(!
$
this
->
map
instanceof
MapperCollection) {
throw
new
MissingMapperException
();
}
return
$
this
->
map
;
}
/**
* @return IdentityInterface
* @throws MissingIdentityException
*/
public
function
getIdentity
()
{
if
(!
$
this
->
identity
instanceof
\
G4
\
DataMapper
\
Common
\IdentityInterface) {
throw
new
MissingIdentityException
();
}
return
$
this
->
identity
;
}
public
function
getRussianDollKey
()
{
if
(!
$
this
->
russianDollKey
instanceof
\
G4
\
RussianDoll
\Key) {
throw
new
MissingRussianDollKeyException
();
}
return
$
this
->
russianDollKey
;
}
public
function
getIdentityMapKey
()
{
if
(
empty
(
$
this
->
identityMapKey
)) {
throw
new
MissingIdentityMapKeyException
();
}
return
$
this
->
identityMapKey
;
}
public
function
setRussianDollKey
(
\
G4
\
RussianDoll
\
Key
$
russianDollKey
)
{
$
this
->
russianDollKey
=
$
russianDollKey
;
return
$
this
;
}
public
function
setIdentityMapKey
(...
$
identityMapKey
)
{
$
this
->
identityMapKey
=
join
(
self
::
DELIMITER
,
$
identityMapKey
);
return
$
this
;
}
public
function
update
(
MapperCollection
$
map
,
IdentityInterface
$
identity
)
{
$
this
->
map
=
$
map
;
$
this
->
identity
=
$
identity
;
$
this
->
action
=
self
::
ACTION_UPDATE
;
return
$
this
;
}
public
function
upsert
(
MapperCollection
$
map
)
{
$
this
->
map
=
$
map
;
$
this
->
action
=
self
::
ACTION_UPSERT
;
return
$
this
;
}
public
function
delete
(
\
G4
\
DataMapper
\
Common
\
IdentityInterface
$
identity
)
{
$
this
->
identity
=
$
identity
;
$
this
->
action
=
self
::
ACTION_DELETE
;
return
$
this
;
}
public
function
insert
(
MapperCollection
$
maps
)
{
$
this
->
map
=
$
maps
;
$
this
->
action
=
self
::
ACTION_INSERT
;
return
$
this
;
}
public
function
isUpsert
()
{
return
$
this
->
getAction
() ===
self
::
ACTION_UPSERT
;
}
public
function
isInsert
()
{
return
$
this
->
getAction
() ===
self
::
ACTION_INSERT
;
}
public
function
isUpdate
()
{
return
$
this
->
getAction
() ===
self
::
ACTION_UPDATE
;
}
public
function
isDelete
()
{
return
$
this
->
getAction
() ===
self
::
ACTION_DELETE
;
}
public
function
isCustomCommand
()
{
return
$
this
->
getAction
() ===
self
::
CUSTOM_COMMAND
;
}
private
function
getAction
()
{
if
(
$
this
->
action
===
self
::
ACTION_INSERT
||
$
this
->
action
===
self
::
ACTION_DELETE
||
$
this
->
action
===
self
::
ACTION_UPDATE
||
$
this
->
action
===
self
::
ACTION_UPSERT
||
$
this
->
action
===
self
::
CUSTOM_COMMAND
) {
return
$
this
->
action
;
}
throw
new
MissingActionException
();
}
public
function
hasCustomCommand
()
{
return
!
empty
(
$
this
->
customCommand
);
}
public
function
getCustomCommand
()
{
if
(!
$
this
->
hasCustomCommand
()) {
throw
new
MissingCustomCommandException
();
}
return
$
this
->
customCommand
;
}
public
function
setCustomCommand
(
$
customCommand
)
{
$
this
->
action
=
self
::
CUSTOM_COMMAND
;
$
this
->
customCommand
=
$
customCommand
;
return
$
this
;
}
}
Back
|
FazBrowse Home
|
New Git URL