@@ -69,21 +69,9 @@ public function __construct(string $pattern, string $timezone)
69
69
];
70
70
}
71
71
72
- /**
73
- * Return the array of Transformer objects.
74
- *
75
- * @return Transformer[] Associative array of Transformer objects (format char => Transformer)
76
- */
77
- public function getTransformers ()
78
- {
79
- return $ this ->transformers ;
80
- }
81
-
82
72
/**
83
73
* Format a DateTime using ICU dateformat pattern.
84
74
*
85
- * @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
86
- *
87
75
* @return string The formatted value
88
76
*/
89
77
public function format (\DateTime $ dateTime )
@@ -98,14 +86,9 @@ public function format(\DateTime $dateTime)
98
86
/**
99
87
* Return the formatted ICU value for the matched date characters.
100
88
*
101
- * @param string $dateChars The date characters to be replaced with a formatted ICU value
102
- * @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
103
- *
104
- * @return string The formatted value
105
- *
106
89
* @throws NotImplementedException When it encounters a not implemented date character
107
90
*/
108
- public function formatReplace ($ dateChars , $ dateTime )
91
+ private function formatReplace (string $ dateChars , \ DateTime $ dateTime ): string
109
92
{
110
93
$ length = \strlen ($ dateChars );
111
94
@@ -167,12 +150,10 @@ public function parse(\DateTime $dateTime, $value)
167
150
/**
168
151
* Retrieve a regular expression to match with a formatted value.
169
152
*
170
- * @param string $pattern The pattern to create the reverse matching regular expression
171
- *
172
153
* @return string The reverse matching regular expression with named captures being formed by the
173
154
* transformer index in the $transformer array
174
155
*/
175
- public function getReverseMatchingRegExp ($ pattern )
156
+ private function getReverseMatchingRegExp (string $ pattern ): string
176
157
{
177
158
$ escapedPattern = preg_quote ($ pattern , '/ ' );
178
159
@@ -189,9 +170,8 @@ public function getReverseMatchingRegExp($pattern)
189
170
return $ this ->replaceQuoteMatch ($ dateChars );
190
171
}
191
172
192
- $ transformers = $ this ->getTransformers ();
193
- if (isset ($ transformers [$ transformerIndex ])) {
194
- $ transformer = $ transformers [$ transformerIndex ];
173
+ if (isset ($ this ->transformers [$ transformerIndex ])) {
174
+ $ transformer = $ this ->transformers [$ transformerIndex ];
195
175
$ captureName = str_repeat ($ transformerIndex , $ length );
196
176
197
177
return "(?P< $ captureName> " .$ transformer ->getReverseMatchingRegExp ($ length ).') ' ;
@@ -203,24 +183,16 @@ public function getReverseMatchingRegExp($pattern)
203
183
204
184
/**
205
185
* Check if the first char of a string is a single quote.
206
- *
207
- * @param string $quoteMatch The string to check
208
- *
209
- * @return bool true if matches, false otherwise
210
186
*/
211
- public function isQuoteMatch ($ quoteMatch )
187
+ private function isQuoteMatch (string $ quoteMatch ): bool
212
188
{
213
189
return "' " === $ quoteMatch [0 ];
214
190
}
215
191
216
192
/**
217
193
* Replaces single quotes at the start or end of a string with two single quotes.
218
- *
219
- * @param string $quoteMatch The string to replace the quotes
220
- *
221
- * @return string A string with the single quotes replaced
222
194
*/
223
- public function replaceQuoteMatch ($ quoteMatch )
195
+ private function replaceQuoteMatch (string $ quoteMatch ): string
224
196
{
225
197
if (preg_match ("/^'+$/ " , $ quoteMatch )) {
226
198
return str_replace ("'' " , "' " , $ quoteMatch );
@@ -231,12 +203,8 @@ public function replaceQuoteMatch($quoteMatch)
231
203
232
204
/**
233
205
* Builds a chars match regular expression.
234
- *
235
- * @param string $specialChars A string of chars to build the regular expression
236
- *
237
- * @return string The chars match regular expression
238
206
*/
239
- protected function buildCharsMatch ($ specialChars )
207
+ private function buildCharsMatch (string $ specialChars ): string
240
208
{
241
209
$ specialCharsArray = str_split ($ specialChars );
242
210
@@ -250,10 +218,8 @@ protected function buildCharsMatch($specialChars)
250
218
/**
251
219
* Normalize a preg_replace match array, removing the numeric keys and returning an associative array
252
220
* with the value and pattern values for the matched Transformer.
253
- *
254
- * @return array
255
221
*/
256
- protected function normalizeArray (array $ data )
222
+ private function normalizeArray (array $ data ): array
257
223
{
258
224
$ ret = [];
259
225
@@ -275,12 +241,9 @@ protected function normalizeArray(array $data)
275
241
* Calculates the Unix timestamp based on the matched values by the reverse matching regular
276
242
* expression of parse().
277
243
*
278
- * @param \DateTime $dateTime The DateTime object to be used to calculate the timestamp
279
- * @param array $options An array with the matched values to be used to calculate the timestamp
280
- *
281
244
* @return bool|int The calculated timestamp or false if matched date is invalid
282
245
*/
283
- protected function calculateUnixTimestamp (\DateTime $ dateTime , array $ options )
246
+ private function calculateUnixTimestamp (\DateTime $ dateTime , array $ options )
284
247
{
285
248
$ options = $ this ->getDefaultValueForOptions ($ options );
286
249
0 commit comments