FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Mapper/src/Mapping.php at master · ScriptFUSION/Mapper · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ScriptFUSION
/
Mapper
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
85
Code
Issues
2
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Mapper
/
src
/
Mapping.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
61 lines (54 loc) · 1.36 KB
Breadcrumbs
Mapper
/
src
/
Mapping.php
Copy path
File metadata and controls
61 lines (54 loc) · 1.36 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
<?php
namespace
ScriptFUSION
\
Mapper
;
use
ScriptFUSION
\
Mapper
\
Strategy
\
Strategy
;
/**
* Represents a mapping of keys and mappable values.
*/
abstract
class
Mapping
{
/**
* @var array
*/
private
$
mapping
;
private
$
wrapped
=
false
;
/**
* Initializes this mapping.
*/
public
function
__construct
()
{
/* Array-based mapping. */
if
(
is_array
(
$
mapping
=
$
this
->
createMapping
())) {
$
this
->
mapping
=
$
mapping
;
}
/* Strategy-based mapping. */
elseif
(
$
mapping
instanceof
Strategy) {
$
this
->
mapping
= [
$
mapping
];
$
this
->
wrapped
=
true
;
}
else
{
throw
new
InvalidMappingException
(
'
Invalid mapping: must be array or an instance of Strategy.
'
);
}
}
/**
* Creates a mapping of key names and expressions or a straegy.
*
* @return array|Strategy Mapping.
*/
abstract
protected
function
createMapping
();
/**
* Converts the mapping to an array.
*
* @return array
*/
public
function
toArray
()
{
return
$
this
->
mapping
;
}
/**
* Gets a value indicating whether the mapping has been wrapped in an array.
*
* @return boolean True if the mapping is wrapped in an outer array, otherwise false.
*/
public
function
isWrapped
()
{
return
$
this
->
wrapped
;
}
}
Back
|
FazBrowse Home
|
New Git URL