|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the timechimp bundle package. |
|
7
|
|
|
* (c) Connect Holland. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace ConnectHolland\TimechimpBundle\Api\Normalizer; |
|
11
|
|
|
|
|
12
|
|
|
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; |
|
13
|
|
|
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; |
|
14
|
|
|
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; |
|
15
|
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; |
|
16
|
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; |
|
17
|
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; |
|
18
|
|
|
|
|
19
|
|
|
class ProjectInsightsNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface |
|
20
|
|
|
{ |
|
21
|
|
|
use DenormalizerAwareTrait; |
|
22
|
|
|
use NormalizerAwareTrait; |
|
23
|
|
|
|
|
24
|
|
|
public function supportsDenormalization($data, $type, $format = null) |
|
25
|
|
|
{ |
|
26
|
|
|
return $type === 'ConnectHolland\\TimechimpBundle\\Api\\Model\\ProjectInsights'; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function supportsNormalization($data, $format = null) |
|
30
|
|
|
{ |
|
31
|
|
|
return is_object($data) && get_class($data) === 'ConnectHolland\\TimechimpBundle\\Api\\Model\\ProjectInsights'; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function denormalize($data, $class, $format = null, array $context = []) |
|
35
|
|
|
{ |
|
36
|
|
|
if (!is_object($data)) { |
|
37
|
|
|
return null; |
|
38
|
|
|
} |
|
39
|
|
|
$object = new \ConnectHolland\TimechimpBundle\Api\Model\ProjectInsights(); |
|
40
|
|
|
if (property_exists($data, 'totalHours') && $data->{'totalHours'} !== null) { |
|
41
|
|
|
$object->setTotalHours($data->{'totalHours'}); |
|
42
|
|
|
} elseif (property_exists($data, 'totalHours') && $data->{'totalHours'} === null) { |
|
43
|
|
|
$object->setTotalHours(null); |
|
44
|
|
|
} |
|
45
|
|
|
if (property_exists($data, 'totalHoursBillable') && $data->{'totalHoursBillable'} !== null) { |
|
46
|
|
|
$object->setTotalHoursBillable($data->{'totalHoursBillable'}); |
|
47
|
|
|
} elseif (property_exists($data, 'totalHoursBillable') && $data->{'totalHoursBillable'} === null) { |
|
48
|
|
|
$object->setTotalHoursBillable(null); |
|
49
|
|
|
} |
|
50
|
|
|
if (property_exists($data, 'totalHoursNonBillable') && $data->{'totalHoursNonBillable'} !== null) { |
|
51
|
|
|
$object->setTotalHoursNonBillable($data->{'totalHoursNonBillable'}); |
|
52
|
|
|
} elseif (property_exists($data, 'totalHoursNonBillable') && $data->{'totalHoursNonBillable'} === null) { |
|
53
|
|
|
$object->setTotalHoursNonBillable(null); |
|
54
|
|
|
} |
|
55
|
|
|
if (property_exists($data, 'totalUninvoiced') && $data->{'totalUninvoiced'} !== null) { |
|
56
|
|
|
$object->setTotalUninvoiced($data->{'totalUninvoiced'}); |
|
57
|
|
|
} elseif (property_exists($data, 'totalUninvoiced') && $data->{'totalUninvoiced'} === null) { |
|
58
|
|
|
$object->setTotalUninvoiced(null); |
|
59
|
|
|
} |
|
60
|
|
|
if (property_exists($data, 'totalInvoiced') && $data->{'totalInvoiced'} !== null) { |
|
61
|
|
|
$object->setTotalInvoiced($data->{'totalInvoiced'}); |
|
62
|
|
|
} elseif (property_exists($data, 'totalInvoiced') && $data->{'totalInvoiced'} === null) { |
|
63
|
|
|
$object->setTotalInvoiced(null); |
|
64
|
|
|
} |
|
65
|
|
|
if (property_exists($data, 'totalWrittenOff') && $data->{'totalWrittenOff'} !== null) { |
|
66
|
|
|
$object->setTotalWrittenOff($data->{'totalWrittenOff'}); |
|
67
|
|
|
} elseif (property_exists($data, 'totalWrittenOff') && $data->{'totalWrittenOff'} === null) { |
|
68
|
|
|
$object->setTotalWrittenOff(null); |
|
69
|
|
|
} |
|
70
|
|
|
if (property_exists($data, 'totalScheduled') && $data->{'totalScheduled'} !== null) { |
|
71
|
|
|
$object->setTotalScheduled($data->{'totalScheduled'}); |
|
72
|
|
|
} elseif (property_exists($data, 'totalScheduled') && $data->{'totalScheduled'} === null) { |
|
73
|
|
|
$object->setTotalScheduled(null); |
|
74
|
|
|
} |
|
75
|
|
|
if (property_exists($data, 'budgetPercentage') && $data->{'budgetPercentage'} !== null) { |
|
76
|
|
|
$object->setBudgetPercentage($data->{'budgetPercentage'}); |
|
77
|
|
|
} elseif (property_exists($data, 'budgetPercentage') && $data->{'budgetPercentage'} === null) { |
|
78
|
|
|
$object->setBudgetPercentage(null); |
|
79
|
|
|
} |
|
80
|
|
|
if (property_exists($data, 'budget') && $data->{'budget'} !== null) { |
|
81
|
|
|
$object->setBudget($data->{'budget'}); |
|
82
|
|
|
} elseif (property_exists($data, 'budget') && $data->{'budget'} === null) { |
|
83
|
|
|
$object->setBudget(null); |
|
84
|
|
|
} |
|
85
|
|
|
if (property_exists($data, 'spend') && $data->{'spend'} !== null) { |
|
86
|
|
|
$object->setSpend($data->{'spend'}); |
|
87
|
|
|
} elseif (property_exists($data, 'spend') && $data->{'spend'} === null) { |
|
88
|
|
|
$object->setSpend(null); |
|
89
|
|
|
} |
|
90
|
|
|
if (property_exists($data, 'remainingBudget') && $data->{'remainingBudget'} !== null) { |
|
91
|
|
|
$object->setRemainingBudget($data->{'remainingBudget'}); |
|
92
|
|
|
} elseif (property_exists($data, 'remainingBudget') && $data->{'remainingBudget'} === null) { |
|
93
|
|
|
$object->setRemainingBudget(null); |
|
94
|
|
|
} |
|
95
|
|
|
if (property_exists($data, 'costs') && $data->{'costs'} !== null) { |
|
96
|
|
|
$object->setCosts($data->{'costs'}); |
|
97
|
|
|
} elseif (property_exists($data, 'costs') && $data->{'costs'} === null) { |
|
98
|
|
|
$object->setCosts(null); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
return $object; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function normalize($object, $format = null, array $context = []) |
|
105
|
|
|
{ |
|
106
|
|
|
$data = new \stdClass(); |
|
107
|
|
|
if (null !== $object->getTotalHours()) { |
|
108
|
|
|
$data->{'totalHours'} = $object->getTotalHours(); |
|
109
|
|
|
} else { |
|
110
|
|
|
$data->{'totalHours'} = null; |
|
111
|
|
|
} |
|
112
|
|
|
if (null !== $object->getTotalHoursBillable()) { |
|
113
|
|
|
$data->{'totalHoursBillable'} = $object->getTotalHoursBillable(); |
|
114
|
|
|
} else { |
|
115
|
|
|
$data->{'totalHoursBillable'} = null; |
|
116
|
|
|
} |
|
117
|
|
|
if (null !== $object->getTotalHoursNonBillable()) { |
|
118
|
|
|
$data->{'totalHoursNonBillable'} = $object->getTotalHoursNonBillable(); |
|
119
|
|
|
} else { |
|
120
|
|
|
$data->{'totalHoursNonBillable'} = null; |
|
121
|
|
|
} |
|
122
|
|
|
if (null !== $object->getTotalUninvoiced()) { |
|
123
|
|
|
$data->{'totalUninvoiced'} = $object->getTotalUninvoiced(); |
|
124
|
|
|
} else { |
|
125
|
|
|
$data->{'totalUninvoiced'} = null; |
|
126
|
|
|
} |
|
127
|
|
|
if (null !== $object->getTotalInvoiced()) { |
|
128
|
|
|
$data->{'totalInvoiced'} = $object->getTotalInvoiced(); |
|
129
|
|
|
} else { |
|
130
|
|
|
$data->{'totalInvoiced'} = null; |
|
131
|
|
|
} |
|
132
|
|
|
if (null !== $object->getTotalWrittenOff()) { |
|
133
|
|
|
$data->{'totalWrittenOff'} = $object->getTotalWrittenOff(); |
|
134
|
|
|
} else { |
|
135
|
|
|
$data->{'totalWrittenOff'} = null; |
|
136
|
|
|
} |
|
137
|
|
|
if (null !== $object->getTotalScheduled()) { |
|
138
|
|
|
$data->{'totalScheduled'} = $object->getTotalScheduled(); |
|
139
|
|
|
} else { |
|
140
|
|
|
$data->{'totalScheduled'} = null; |
|
141
|
|
|
} |
|
142
|
|
|
if (null !== $object->getBudgetPercentage()) { |
|
143
|
|
|
$data->{'budgetPercentage'} = $object->getBudgetPercentage(); |
|
144
|
|
|
} else { |
|
145
|
|
|
$data->{'budgetPercentage'} = null; |
|
146
|
|
|
} |
|
147
|
|
|
if (null !== $object->getBudget()) { |
|
148
|
|
|
$data->{'budget'} = $object->getBudget(); |
|
149
|
|
|
} else { |
|
150
|
|
|
$data->{'budget'} = null; |
|
151
|
|
|
} |
|
152
|
|
|
if (null !== $object->getSpend()) { |
|
153
|
|
|
$data->{'spend'} = $object->getSpend(); |
|
154
|
|
|
} else { |
|
155
|
|
|
$data->{'spend'} = null; |
|
156
|
|
|
} |
|
157
|
|
|
if (null !== $object->getRemainingBudget()) { |
|
158
|
|
|
$data->{'remainingBudget'} = $object->getRemainingBudget(); |
|
159
|
|
|
} else { |
|
160
|
|
|
$data->{'remainingBudget'} = null; |
|
161
|
|
|
} |
|
162
|
|
|
if (null !== $object->getCosts()) { |
|
163
|
|
|
$data->{'costs'} = $object->getCosts(); |
|
164
|
|
|
} else { |
|
165
|
|
|
$data->{'costs'} = null; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
return $data; |
|
169
|
|
|
} |
|
170
|
|
|
} |
|
171
|
|
|
|