Creator.php
25.7 KB
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;
use Carbon\CarbonTimeZone;
use Carbon\Exceptions\InvalidDateException;
use Carbon\Translator;
use DateTimeInterface;
use InvalidArgumentException;
/**
* Trait Creator.
*
* Static creators.
*
* Depends on the following methods:
*
* @method static Carbon|CarbonImmutable getTestNow()
*/
trait Creator
{
/**
* The errors that can occur.
*
* @var array
*/
protected static $lastErrors;
/**
* Create a new Carbon instance.
*
* Please see the testing aids section (specifically static::setTestNow())
* for more on the possibility of this constructor returning a test instance.
*
* @param string|null $time
* @param \DateTimeZone|string|null $tz
*/
public function __construct($time = null, $tz = null)
{
if (is_int($time)) {
$time = "@$time";
}
$originalTz = $tz;
// If the class has a test now set and we are trying to create a now()
// instance then override as required
$isNow = empty($time) || $time === 'now';
if (method_exists(static::class, 'hasTestNow') &&
method_exists(static::class, 'getTestNow') &&
static::hasTestNow() &&
($isNow || static::hasRelativeKeywords($time))
) {
static::mockConstructorParameters($time, $tz);
}
/** @var CarbonTimeZone $timezone */
$timezone = $this->autoDetectTimeZone($tz, $originalTz);
// Work-around for PHP bug https://bugs.php.net/bug.php?id=67127
if (strpos((string) .1, '.') === false) {
$locale = setlocale(LC_NUMERIC, '0');
setlocale(LC_NUMERIC, 'C');
}
parent::__construct($time, $timezone);
if (isset($locale)) {
setlocale(LC_NUMERIC, $locale);
}
static::setLastErrors(parent::getLastErrors());
}
/**
* Create a Carbon instance from a DateTime one.
*
* @param \DateTimeInterface $date
*
* @return static|CarbonInterface
*/
public static function instance($date)
{
if ($date instanceof static) {
return clone $date;
}
static::expectDateTime($date);
$instance = new static($date->format('Y-m-d H:i:s.u'), $date->getTimezone());
if ($date instanceof CarbonInterface || $date instanceof Options) {
$instance->settings($date->getSettings());
}
return $instance;
}
/**
* Create a carbon instance from a string.
*
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
*
* @param string|null $time
* @param \DateTimeZone|string|null $tz
*
* @return static|CarbonInterface
*/
public static function rawParse($time = null, $tz = null)
{
if ($time instanceof DateTimeInterface) {
return static::instance($time);
}
return new static($time, $tz);
}
/**
* Create a carbon instance from a string.
*
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
*
* @param string|null $time
* @param \DateTimeZone|string|null $tz
*
* @return static|CarbonInterface
*/
public static function parse($time = null, $tz = null)
{
$function = static::$parseFunction;
if (!$function) {
return static::rawParse($time, $tz);
}
if (is_string($function) && method_exists(static::class, $function)) {
$function = [static::class, $function];
}
return $function(...func_get_args());
}
/**
* Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
*
* @param string $time
* @param string $locale
* @param \DateTimeZone|string|null $tz
*
* @return static|CarbonInterface
*/
public static function parseFromLocale($time, $locale, $tz = null)
{
return static::rawParse(static::translateTimeString($time, $locale, 'en'), $tz);
}
/**
* Get a Carbon instance for the current date and time.
*
* @param \DateTimeZone|string|null $tz
*
* @return static|CarbonInterface
*/
public static function now($tz = null)
{
return new static(null, $tz);
}
/**
* Create a Carbon instance for today.
*
* @param \DateTimeZone|string|null $tz
*
* @return static|CarbonInterface
*/
public static function today($tz = null)
{
return static::rawParse('today', $tz);
}
/**
* Create a Carbon instance for tomorrow.
*
* @param \DateTimeZone|string|null $tz
*
* @return static|CarbonInterface
*/
public static function tomorrow($tz = null)
{
return static::rawParse('tomorrow', $tz);
}
/**
* Create a Carbon instance for yesterday.
*
* @param \DateTimeZone|string|null $tz
*
* @return static|CarbonInterface
*/
public static function yesterday($tz = null)
{
return static::rawParse('yesterday', $tz);
}
/**
* Create a Carbon instance for the greatest supported date.
*
* @return static|CarbonInterface
*/
public static function maxValue()
{
if (self::$PHPIntSize === 4) {
// 32 bit
return static::createFromTimestamp(PHP_INT_MAX); // @codeCoverageIgnore
}
// 64 bit
return static::create(9999, 12, 31, 23, 59, 59);
}
/**
* Create a Carbon instance for the lowest supported date.
*
* @return static|CarbonInterface
*/
public static function minValue()
{
if (self::$PHPIntSize === 4) {
// 32 bit
return static::createFromTimestamp(~PHP_INT_MAX); // @codeCoverageIgnore
}
// 64 bit
return static::create(1, 1, 1, 0, 0, 0);
}
/**
* Create a new Carbon instance from a specific date and time.
*
* If any of $year, $month or $day are set to null their now() values will
* be used.
*
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
*
* If $hour is not null then the default values for $minute and $second
* will be 0.
*
* @param int|null $year
* @param int|null $month
* @param int|null $day
* @param int|null $hour
* @param int|null $minute
* @param int|null $second
* @param \DateTimeZone|string|null $tz
*
* @throws \InvalidArgumentException
*
* @return static|CarbonInterface
*/
public static function create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null)
{
if (is_string($year) && !is_numeric($year)) {
return static::parse($year, $tz);
}
$defaults = null;
$getDefault = function ($unit) use ($tz, &$defaults) {
if ($defaults === null) {
$now = static::hasTestNow() ? static::getTestNow() : static::now($tz);
$defaults = array_combine([
'year',
'month',
'day',
'hour',
'minute',
'second',
], explode('-', $now->rawFormat('Y-n-j-G-i-s.u')));
}
return $defaults[$unit];
};
$year = $year === null ? $getDefault('year') : $year;
$month = $month === null ? $getDefault('month') : $month;
$day = $day === null ? $getDefault('day') : $day;
$hour = $hour === null ? $getDefault('hour') : $hour;
$minute = $minute === null ? $getDefault('minute') : $minute;
$second = $second === null ? $getDefault('second') : $second;
$fixYear = null;
if ($year < 0) {
$fixYear = $year;
$year = 0;
} elseif ($year > 9999) {
$fixYear = $year - 9999;
$year = 9999;
}
$second = ($second < 10 ? '0' : '').number_format($second, 6);
/** @var CarbonImmutable|Carbon $instance */
$instance = static::rawCreateFromFormat('!Y-n-j G:i:s.u', sprintf('%s-%s-%s %s:%02s:%02s', $year, $month, $day, $hour, $minute, $second), $tz);
if ($fixYear !== null) {
$instance = $instance->addYears($fixYear);
}
return $instance;
}
/**
* Create a new safe Carbon instance from a specific date and time.
*
* If any of $year, $month or $day are set to null their now() values will
* be used.
*
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
*
* If $hour is not null then the default values for $minute and $second
* will be 0.
*
* If one of the set values is not valid, an \InvalidArgumentException
* will be thrown.
*
* @param int|null $year
* @param int|null $month
* @param int|null $day
* @param int|null $hour
* @param int|null $minute
* @param int|null $second
* @param \DateTimeZone|string|null $tz
*
* @throws \Carbon\Exceptions\InvalidDateException|\InvalidArgumentException
*
* @return static|CarbonInterface|false
*/
public static function createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null)
{
$fields = static::getRangesByUnit();
foreach ($fields as $field => $range) {
if ($$field !== null && (!is_int($$field) || $$field < $range[0] || $$field > $range[1])) {
if (static::isStrictModeEnabled()) {
throw new InvalidDateException($field, $$field);
}
return false;
}
}
$instance = static::create($year, $month, $day, $hour, $minute, $second, $tz);
foreach (array_reverse($fields) as $field => $range) {
if ($$field !== null && (!is_int($$field) || $$field !== $instance->$field)) {
if (static::isStrictModeEnabled()) {
throw new InvalidDateException($field, $$field);
}
return false;
}
}
return $instance;
}
/**
* Create a Carbon instance from just a date. The time portion is set to now.
*
* @param int|null $year
* @param int|null $month
* @param int|null $day
* @param \DateTimeZone|string|null $tz
*
* @throws \InvalidArgumentException
*
* @return static|CarbonInterface
*/
public static function createFromDate($year = null, $month = null, $day = null, $tz = null)
{
return static::create($year, $month, $day, null, null, null, $tz);
}
/**
* Create a Carbon instance from just a date. The time portion is set to midnight.
*
* @param int|null $year
* @param int|null $month
* @param int|null $day
* @param \DateTimeZone|string|null $tz
*
* @return static|CarbonInterface
*/
public static function createMidnightDate($year = null, $month = null, $day = null, $tz = null)
{
return static::create($year, $month, $day, 0, 0, 0, $tz);
}
/**
* Create a Carbon instance from just a time. The date portion is set to today.
*
* @param int|null $hour
* @param int|null $minute
* @param int|null $second
* @param \DateTimeZone|string|null $tz
*
* @throws \InvalidArgumentException
*
* @return static|CarbonInterface
*/
public static function createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null)
{
return static::create(null, null, null, $hour, $minute, $second, $tz);
}
/**
* Create a Carbon instance from a time string. The date portion is set to today.
*
* @param string $time
* @param \DateTimeZone|string|null $tz
*
* @throws \InvalidArgumentException
*
* @return static|CarbonInterface
*/
public static function createFromTimeString($time, $tz = null)
{
return static::today($tz)->setTimeFromTimeString($time);
}
/**
* @param string $format Datetime format
* @param string $time
* @param \DateTimeZone|string|false|null $originalTz
*
* @return \DateTimeInterface|false
*/
private static function createFromFormatAndTimezone($format, $time, $originalTz)
{
// Work-around for https://bugs.php.net/bug.php?id=75577
// @codeCoverageIgnoreStart
if (version_compare(PHP_VERSION, '7.3.0-dev', '<')) {
$format = str_replace('.v', '.u', $format);
}
// @codeCoverageIgnoreEnd
if ($originalTz === null) {
return parent::createFromFormat($format, $time);
}
$tz = is_int($originalTz)
? @timezone_name_from_abbr(null, floatval($originalTz * 3600), 1)
: $originalTz;
$tz = static::safeCreateDateTimeZone($tz, $originalTz);
if ($tz === false) {
return false;
}
return parent::createFromFormat($format, $time, $tz);
}
/**
* Create a Carbon instance from a specific format.
*
* @param string $format Datetime format
* @param string $time
* @param \DateTimeZone|string|false|null $tz
*
* @throws InvalidArgumentException
*
* @return static|CarbonInterface|false
*/
public static function rawCreateFromFormat($format, $time, $tz = null)
{
if (preg_match('/(?<!\\\\)(?:\\\\{2})*(a|A)/', $format, $aMatches, PREG_OFFSET_CAPTURE) &&
preg_match('/(?<!\\\\)(?:\\\\{2})*(h|g|H|G)/', $format, $hMatches, PREG_OFFSET_CAPTURE) &&
$aMatches[1][1] < $hMatches[1][1] &&
preg_match('/(am|pm|AM|PM)/', $time)
) {
$format = preg_replace('/^(.*)(?<!\\\\)((?:\\\\{2})*)(a|A)(.*)$/U', '$1$2$4 $3', $format);
$time = preg_replace('/^(.*)(am|pm|AM|PM)(.*)$/U', '$1$3 $2', $time);
}
// First attempt to create an instance, so that error messages are based on the unmodified format.
$date = self::createFromFormatAndTimezone($format, $time, $tz);
$lastErrors = parent::getLastErrors();
if (($mock = static::getTestNow()) && $date instanceof DateTimeInterface) {
// Set timezone from mock if custom timezone was neither given directly nor as a part of format.
// First let's skip the part that will be ignored by the parser.
$nonEscaped = '(?<!\\\\)(\\\\{2})*';
$nonIgnored = preg_replace("/^.*{$nonEscaped}!/s", '', $format);
if ($tz === null && !preg_match("/{$nonEscaped}[eOPT]/", $nonIgnored)) {
$tz = $mock->getTimezone();
}
// Set microseconds to zero to match behavior of DateTime::createFromFormat()
// See https://bugs.php.net/bug.php?id=74332
$mock = $mock->copy()->microsecond(0);
// Prepend mock datetime only if the format does not contain non escaped unix epoch reset flag.
if (!preg_match("/{$nonEscaped}[!|]/", $format)) {
$format = static::MOCK_DATETIME_FORMAT.' '.$format;
$time = ($mock instanceof self ? $mock->rawFormat(static::MOCK_DATETIME_FORMAT) : $mock->format(static::MOCK_DATETIME_FORMAT)).' '.$time;
}
// Regenerate date from the modified format to base result on the mocked instance instead of now.
$date = self::createFromFormatAndTimezone($format, $time, $tz);
}
if ($date instanceof DateTimeInterface) {
$instance = static::instance($date);
$instance::setLastErrors($lastErrors);
return $instance;
}
if (static::isStrictModeEnabled()) {
throw new InvalidArgumentException(implode(PHP_EOL, $lastErrors['errors']));
}
return false;
}
/**
* Create a Carbon instance from a specific format.
*
* @param string $format Datetime format
* @param string $time
* @param \DateTimeZone|string|false|null $tz
*
* @throws InvalidArgumentException
*
* @return static|CarbonInterface|false
*/
public static function createFromFormat($format, $time, $tz = null)
{
$function = static::$createFromFormatFunction;
if (!$function) {
return static::rawCreateFromFormat($format, $time, $tz);
}
if (is_string($function) && method_exists(static::class, $function)) {
$function = [static::class, $function];
}
return $function(...func_get_args());
}
/**
* Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
*
* @param string $format Datetime format
* @param string $time
* @param \DateTimeZone|string|false|null $tz optional timezone
* @param string|null $locale locale to be used for LTS, LT, LL, LLL, etc. macro-formats (en by fault, unneeded if no such macro-format in use)
* @param \Symfony\Component\Translation\TranslatorInterface $translator optional custom translator to use for macro-formats
*
* @throws InvalidArgumentException
*
* @return static|CarbonInterface|false
*/
public static function createFromIsoFormat($format, $time, $tz = null, $locale = 'en', $translator = null)
{
$format = preg_replace_callback('/(?<!\\\\)(\\\\{2})*(LTS|LT|[Ll]{1,4})/', function ($match) use ($locale, $translator) {
[$code] = $match;
static $formats = null;
if ($formats === null) {
$translator = $translator ?: Translator::get($locale);
$formats = [
'LT' => static::getTranslationMessageWith($translator, 'formats.LT', $locale, 'h:mm A'),
'LTS' => static::getTranslationMessageWith($translator, 'formats.LTS', $locale, 'h:mm:ss A'),
'L' => static::getTranslationMessageWith($translator, 'formats.L', $locale, 'MM/DD/YYYY'),
'LL' => static::getTranslationMessageWith($translator, 'formats.LL', $locale, 'MMMM D, YYYY'),
'LLL' => static::getTranslationMessageWith($translator, 'formats.LLL', $locale, 'MMMM D, YYYY h:mm A'),
'LLLL' => static::getTranslationMessageWith($translator, 'formats.LLLL', $locale, 'dddd, MMMM D, YYYY h:mm A'),
];
}
return $formats[$code] ?? preg_replace_callback(
'/MMMM|MM|DD|dddd/',
function ($code) {
return mb_substr($code[0], 1);
},
$formats[strtoupper($code)] ?? ''
);
}, $format);
$format = preg_replace_callback('/(?<!\\\\)(\\\\{2})*('.CarbonInterface::ISO_FORMAT_REGEXP.'|[A-Za-z])/', function ($match) {
[$code] = $match;
static $replacements = null;
if ($replacements === null) {
$replacements = [
'OD' => 'd',
'OM' => 'M',
'OY' => 'Y',
'OH' => 'G',
'Oh' => 'g',
'Om' => 'i',
'Os' => 's',
'D' => 'd',
'DD' => 'd',
'Do' => 'd',
'd' => '!',
'dd' => '!',
'ddd' => 'D',
'dddd' => 'D',
'DDD' => 'z',
'DDDD' => 'z',
'DDDo' => 'z',
'e' => '!',
'E' => '!',
'H' => 'G',
'HH' => 'H',
'h' => 'g',
'hh' => 'h',
'k' => 'G',
'kk' => 'G',
'hmm' => 'gi',
'hmmss' => 'gis',
'Hmm' => 'Gi',
'Hmmss' => 'Gis',
'm' => 'i',
'mm' => 'i',
'a' => 'a',
'A' => 'a',
's' => 's',
'ss' => 's',
'S' => '*',
'SS' => '*',
'SSS' => '*',
'SSSS' => '*',
'SSSSS' => '*',
'SSSSSS' => 'u',
'SSSSSSS' => 'u*',
'SSSSSSSS' => 'u*',
'SSSSSSSSS' => 'u*',
'M' => 'm',
'MM' => 'm',
'MMM' => 'M',
'MMMM' => 'M',
'Mo' => 'm',
'Q' => '!',
'Qo' => '!',
'G' => '!',
'GG' => '!',
'GGG' => '!',
'GGGG' => '!',
'GGGGG' => '!',
'g' => '!',
'gg' => '!',
'ggg' => '!',
'gggg' => '!',
'ggggg' => '!',
'W' => '!',
'WW' => '!',
'Wo' => '!',
'w' => '!',
'ww' => '!',
'wo' => '!',
'x' => 'U???',
'X' => 'U',
'Y' => 'Y',
'YY' => 'y',
'YYYY' => 'Y',
'YYYYY' => 'Y',
'YYYYYY' => 'Y',
'z' => 'e',
'zz' => 'e',
'Z' => 'e',
'ZZ' => 'e',
];
}
$format = $replacements[$code] ?? '?';
if ($format === '!') {
throw new InvalidArgumentException("Format $code not supported for creation.");
}
return $format;
}, $format);
return static::rawCreateFromFormat($format, $time, $tz);
}
/**
* Create a Carbon instance from a specific format and a string in a given language.
*
* @param string $format Datetime format
* @param string $locale
* @param string $time
* @param \DateTimeZone|string|false|null $tz
*
* @throws InvalidArgumentException
*
* @return static|CarbonInterface|false
*/
public static function createFromLocaleFormat($format, $locale, $time, $tz = null)
{
return static::rawCreateFromFormat($format, static::translateTimeString($time, $locale, 'en'), $tz);
}
/**
* Create a Carbon instance from a specific ISO format and a string in a given language.
*
* @param string $format Datetime ISO format
* @param string $locale
* @param string $time
* @param \DateTimeZone|string|false|null $tz
*
* @throws InvalidArgumentException
*
* @return static|CarbonInterface|false
*/
public static function createFromLocaleIsoFormat($format, $locale, $time, $tz = null)
{
$time = static::translateTimeString($time, $locale, 'en', CarbonInterface::TRANSLATE_MONTHS | CarbonInterface::TRANSLATE_DAYS | CarbonInterface::TRANSLATE_MERIDIEM);
return static::createFromIsoFormat($format, $time, $tz, $locale);
}
/**
* Make a Carbon instance from given variable if possible.
*
* Always return a new instance. Parse only strings and only these likely to be dates (skip intervals
* and recurrences). Throw an exception for invalid format, but otherwise return null.
*
* @param mixed $var
*
* @return static|CarbonInterface|null
*/
public static function make($var)
{
if ($var instanceof DateTimeInterface) {
return static::instance($var);
}
$date = null;
if (is_string($var)) {
$var = trim($var);
$first = substr($var, 0, 1);
if (is_string($var) && $first !== 'P' && $first !== 'R' && preg_match('/[a-z0-9]/i', $var)) {
$date = static::parse($var);
}
}
return $date;
}
/**
* Set last errors.
*
* @param array $lastErrors
*
* @return void
*/
private static function setLastErrors(array $lastErrors)
{
static::$lastErrors = $lastErrors;
}
/**
* {@inheritdoc}
*/
public static function getLastErrors()
{
return static::$lastErrors;
}
}