|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Papper; |
|
4
|
|
|
|
|
5
|
|
|
use Papper\Internal\MemberGetterInterface; |
|
6
|
|
|
use Papper\Internal\MemberSetterInterface; |
|
7
|
|
|
|
|
8
|
|
|
class PropertyMap |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @var MemberGetterInterface |
|
12
|
|
|
*/ |
|
13
|
|
|
private $sourceGetter; |
|
14
|
|
|
/** |
|
15
|
|
|
* @var MemberSetterInterface |
|
16
|
|
|
*/ |
|
17
|
|
|
private $destinationSetter; |
|
18
|
|
|
/** |
|
19
|
|
|
* @var ValueConverterInterface |
|
20
|
|
|
*/ |
|
21
|
|
|
private $valueConverter = null; |
|
22
|
|
|
/** |
|
23
|
|
|
* @var bool |
|
24
|
|
|
*/ |
|
25
|
|
|
private $isIgnored = false; |
|
26
|
|
|
/** |
|
27
|
|
|
* @var mixed |
|
28
|
|
|
*/ |
|
29
|
|
|
private $nullSubtitute = null; |
|
30
|
|
|
|
|
31
|
|
|
public function __construct(MemberSetterInterface $setter, MemberGetterInterface $getter = null) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->destinationSetter = $setter; |
|
34
|
|
|
$this->sourceGetter = $getter; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function getMemberName() |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
|
|
return $this->destinationSetter->getName(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function getDestinationSetter() |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->destinationSetter; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function getSourceGetter() |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->sourceGetter; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function setSourceGetter(MemberGetterInterface $sourceGetter) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->sourceGetter = $sourceGetter; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function getValueConverter() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->valueConverter; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function setValueConverter(ValueConverterInterface $valueConverter) |
|
63
|
|
|
{ |
|
64
|
|
|
$this->valueConverter = $valueConverter; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function hasValueConverter() |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->valueConverter !== null; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getNullSubtitute() |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->nullSubtitute; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function setNullSubtitute($nullSubtitute) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->nullSubtitute = $nullSubtitute; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function ignore() |
|
83
|
|
|
{ |
|
84
|
|
|
$this->isIgnored = true; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function isIgnored() |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->isIgnored; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function isMapped() |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->isIgnored || $this->sourceGetter !== null; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.