PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.1.1
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.1.1
2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 1.7.2 All 33 releases
fluent-booking / vendor / wpfluent / framework / src / WPFluent / Validator / MessageBag.php

MessageBag.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution 2.1.1, at vendor/wpfluent/framework/src/WPFluent/Validator/MessageBag.php

851 lines 24.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBooking\Framework\Validator;
4
5 use FluentBooking\Framework\Support\Arr;
6
7 trait MessageBag
8 {
9 /**
10 * The default message bag.
11 *
12 * @var array
13 */
14 protected $bag = [
15 'array' => 'The :attribute must be an array.',
16 'alpha' => 'The :attribute must contain only alphabetic characters.',
17 'alphanum' => 'The :attribute must contain only alphanumeric characters.',
18 'alphadash' => 'The :attribute must contain only alphanumeric and _- characters.',
19 'email' => 'The :attribute must be a valid email address.',
20 'date_format' => 'Unable to format the :attribute field from the :value format string.',
21 'exists' => 'The selected :attribute is invalid.',
22 'gt' => 'The :attribute must be greater than :value.',
23 'lt' => 'The :attribute must be less than :value.',
24 'gte' => 'The :attribute must be greater than or equal to :value.',
25 'lte' => 'The :attribute must be less than or equal to :value.',
26 'in' => 'The selected :attribute is invalid.',
27 'not_in' => 'The selected :attribute is invalid.',
28 'max' => [
29 'numeric' => 'The :attribute may not be greater than :max.',
30 'file' => 'The :attribute may not be greater than :max kilobytes.',
31 'string' => 'The :attribute may not be greater than :max characters.',
32 'array' => 'The :attribute may not have more than :max items.',
33 ],
34 'mimes' => 'The :attribute must be a file of type: :values.',
35 'mimetypes' => 'The :attribute must be a file of type: :values.',
36 'min' => [
37 'numeric' => 'The :attribute must be at least :min.',
38 'file' => 'The :attribute must be at least :min kilobytes.',
39 'string' => 'The :attribute must be at least :min characters.',
40 'array' => 'The :attribute must have at least :min items.',
41 ],
42 'string' => 'The :attribute must be a string.',
43 'integer' => 'The :attribute must be an integer.',
44 'numeric' => 'The :attribute must be a number.',
45 'required' => 'The :attribute field is required.',
46 'required_array_keys' => 'The :attribute must be an array and should contain :keys.',
47 'required_if' => 'The :attribute field is required when :other is :value.',
48 'required_with' => 'The :attribute field is required when the :other field is present.',
49 'required_with_all' => 'The :attribute field is required when the :other field is present.',
50 'required_without' => 'The :attribute field is required when the :other field is not present.',
51 'required_without_all' => 'The :attribute field is required when the :other fields are not present.',
52 'same' => 'The :attribute and :other must match.',
53 'size' => [
54 'numeric' => 'The :attribute must be :size.',
55 'file' => 'The :attribute must be :size kilobytes.',
56 'string' => 'The :attribute must be :size characters.',
57 'array' => 'The :attribute must contain :size items.',
58 ],
59 'url' => 'The :attribute format is invalid.',
60 'unique' => 'The :attribute attribute is already taken and must be unique.',
61 'digits' => 'The :attribute must be :digits characters.'
62 ];
63
64 /**
65 * Generate a validation error message.
66 *
67 * @param $attribute
68 * @param $rule
69 * @param $parameters
70 * @param $originalRuleKey
71 *
72 * @return mixed
73 */
74 protected function generate($attribute, $rule, $parameters, $originalRuleKey = null)
75 {
76 $method = 'replace'.str_replace(
77 ' ', '', ucwords(str_replace(['-', '_'], ' ', $rule))
78 );
79
80 $originalKey = '';
81
82 if (!empty($originalRuleKey)){
83 $originalKey = $originalRuleKey.'.'.$rule;
84 }
85
86 if ($this->hasMethod($method)) {
87 return $this->$method($attribute, $parameters, $originalKey);
88 } else {
89 return $this->generateDefaultMessage($attribute, $parameters);
90 }
91 }
92
93 /**
94 * Fallback message generator for the failed validation.
95 * @param string $attribute
96 * @param array $parameters
97 * @return string
98 */
99 protected function generateDefaultMessage($attribute, $parameters)
100 {
101 $msg = "The {$attribute} field has been failed the validation";
102
103 if ($parameters) {
104 $msg .= " with parameter \"{$parameters[0]}\"";
105 }
106
107 return ($msg . '.');
108 }
109
110
111 /**
112 * Get the replacement text of the error message.
113 *
114 * @param $customKey
115 * @param $bagAccessor
116 * @param $originalKey
117 *
118 * @return string
119 */
120 protected function getReplacementText($customKey, $bagAccessor, $originalKey = null)
121 {
122 if (isset($this->customMessages[$customKey])) {
123 return $this->customMessages[$customKey];
124 } elseif (isset($this->customMessages[$originalKey])) {
125 return $this->customMessages[$originalKey];
126 }
127
128 return Arr::get($this->bag, $bagAccessor, '');
129 }
130
131 /**
132 * Make bag accessor key.
133 *
134 * @param $attribute
135 * @param $rule
136 *
137 * @return string
138 */
139 protected function makeBagKey($attribute, $rule)
140 {
141 $type = $this->deduceType(
142 $this->getValue($attribute), $attribute
143 );
144
145 return $rule.'.'.$type;
146 }
147
148 /**
149 * Replace all place-holders for the string rule.
150 *
151 * @param $attribute
152 * @param $parameters
153 * @param $originalKey
154 * @return string
155 */
156 protected function replaceString($attribute, $parameters, $originalKey)
157 {
158 $text = $this->getReplacementText(
159 $attribute.'.string', 'string', $originalKey
160 );
161
162 return str_replace(':attribute', $attribute, $text);
163 }
164
165 /**
166 * Replace all place-holders for the int|integer rule.
167 *
168 * @param $attribute
169 * @param $parameters
170 * @param $originalKey
171 * @return string
172 */
173 protected function replaceInt($attribute, $parameters, $originalKey)
174 {
175 return $this->replaceInteger($attribute, $parameters, $originalKey);
176 }
177
178 /**
179 * Replace all place-holders for the int|integer rule.
180 *
181 * @param $attribute
182 * @param $parameters
183 * @param $originalKey
184 *
185 * @return string
186 */
187 protected function replaceInteger($attribute, $parameters, $originalKey)
188 {
189 $text = $this->getReplacementText(
190 $attribute.'.integer', 'integer', $originalKey
191 );
192
193 return str_replace(':attribute', $attribute, $text);
194 }
195
196 /**
197 * Replace all place-holders for the alpha rule.
198 *
199 * @param $attribute
200 * @param $parameters
201 * @param $originalKey
202 *
203 * @return string
204 */
205 protected function replaceAlpha($attribute, $parameters, $originalKey)
206 {
207 $text = $this->getReplacementText(
208 $attribute.'.alpha', 'alpha', $originalKey
209 );
210
211 return str_replace(':attribute', $attribute, $text);
212 }
213
214 /**
215 * Replace all place-holders for the alphanum rule.
216 *
217 * @param $attribute
218 * @param $parameters
219 * @param $originalKey
220 *
221 * @return string
222 */
223 protected function replaceAlphanum($attribute, $parameters, $originalKey)
224 {
225 $text = $this->getReplacementText(
226 $attribute.'.alphanum', 'alphanum', $originalKey
227 );
228
229 return str_replace(':attribute', $attribute, $text);
230 }
231
232 /**
233 * Replace all place-holders for the alphadash rule.
234 *
235 * @param $attribute
236 * @param $parameters
237 * @param $originalKey
238 *
239 * @return string
240 */
241 protected function replaceAlphadash($attribute, $parameters, $originalKey)
242 {
243 $text = $this->getReplacementText(
244 $attribute.'.alphadash', 'alphadash', $originalKey
245 );
246
247 return str_replace(':attribute', $attribute, $text);
248 }
249
250 /**
251 * Replace all place-holders for the required rule.
252 *
253 * @param $attribute
254 * @param $parameters
255 * @param $originalKey
256 *
257 * @return string
258 */
259 protected function replaceRequired($attribute, $parameters, $originalKey)
260 {
261 $text = $this->getReplacementText(
262 $attribute.'.required', 'required', $originalKey
263 );
264
265 return str_replace(':attribute', $attribute, $text);
266 }
267
268 /**
269 * Replace all place-holders for the required if rule.
270 *
271 * @param $attribute
272 * @param $parameters
273 * @param $originalKey
274 *
275 * @return string
276 */
277 protected function replaceRequiredIf($attribute, $parameters, $originalKey)
278 {
279 if (preg_match('/\.\d\./', $attribute, $matches)) {
280 $parameters[0] = str_replace(['.*.'], $matches, $parameters[0]);
281 }
282
283 $text = $this->getReplacementText($attribute.'.required_if', 'required_if', $originalKey);
284
285 $value = end($parameters);
286
287 return str_replace([
288 ':attribute', ':other', ':value'],
289 [$attribute, $parameters[0], $value],
290 $text
291 );
292 }
293
294 /**
295 * Replace all place-holders for the required with rule.
296 *
297 * @param $attribute
298 * @param $parameters
299 * @param $originalKey
300 *
301 * @return string
302 */
303 protected function replaceRequiredWith($attribute, $parameters, $originalKey)
304 {
305 if (preg_match('/\.\d\./', $attribute, $matches)) {
306 $parameters[0] = str_replace(['.*.'], $matches, $parameters[0]);
307 }
308
309 $text = $this->getReplacementText($attribute.'.required_with', 'required_with', $originalKey);
310
311 $other = '';
312
313 if (count($parameters) === 1) {
314 $other = $parameters[0];
315 } elseif (count($parameters) === 2) {
316 $other = implode(' or ', $parameters);
317 } else {
318 $last = array_pop($parameters);
319 $other = implode(', ', $parameters) . ' or ' . $last;
320 }
321
322 return str_replace([
323 ':attribute', ':other'],
324 [$attribute, $other],
325 $text
326 );
327 }
328
329 /**
330 * Replace all place-holders for the required with all rule.
331 *
332 * @param $attribute
333 * @param $parameters
334 * @param $originalKey
335 *
336 * @return string
337 */
338 protected function replaceRequiredWithAll($attribute, $parameters, $originalKey)
339 {
340 if (preg_match('/\.\d\./', $attribute, $matches)) {
341 $parameters[0] = str_replace(['.*.'], $matches, $parameters[0]);
342 }
343
344 $text = $this->getReplacementText($attribute.'.required_with_all', 'required_with_all', $originalKey);
345
346 $other = '';
347
348 if (count($parameters) === 1) {
349 $other = $parameters[0];
350 } elseif (count($parameters) === 2) {
351 $other = $parameters[0] . ' and ' . $parameters[1];
352 } else {
353 $last = array_pop($parameters);
354 $other = 'all ' . implode(', ', $parameters) . ' and ' . $last;
355 }
356
357 $text = 'The :attribute field is required when :other field(s) are present.';
358
359 return str_replace(
360 [':attribute', ':other'],
361 [$attribute, $other],
362 $text
363 );
364 }
365
366 /**
367 * Replace all place-holders for the required without rule.
368 *
369 * @param string $attribute
370 * @param array $parameters
371 * @param string $originalKey
372 * @return string
373 */
374 protected function replaceRequiredWithout($attribute, $parameters, $originalKey)
375 {
376 if (preg_match('/\.\d\./', $attribute, $matches)) {
377 $parameters[0] = str_replace(['.*.'], $matches, $parameters[0]);
378 }
379
380 $text = $this->getReplacementText($attribute . '.required_without', 'required_without', $originalKey);
381
382 $other = '';
383
384 if (count($parameters) === 1) {
385 $other = $parameters[0];
386 } elseif (count($parameters) === 2) {
387 $other = implode(' or ', $parameters);
388 } else {
389 $last = array_pop($parameters);
390 $other = implode(', ', $parameters) . ' or ' . $last;
391 }
392
393 // Default message
394 $text = 'The :attribute field is required when :other field(s) are not present.';
395
396 return str_replace(
397 [':attribute', ':other'],
398 [$attribute, $other],
399 $text
400 );
401 }
402
403 /**
404 * Replace all place-holders for the required without all rule.
405 *
406 * @param string $attribute
407 * @param array $parameters
408 * @param string $originalKey
409 * @return string
410 */
411 protected function replaceRequiredWithoutAll($attribute, $parameters, $originalKey)
412 {
413 if (preg_match('/\.\d\./', $attribute, $matches)) {
414 $parameters[0] = str_replace(['.*.'], $matches, $parameters[0]);
415 }
416
417 $text = $this->getReplacementText($attribute . '.required_without_all', 'required_without_all', $originalKey);
418
419 $other = '';
420
421 if (count($parameters) === 1) {
422 $other = $parameters[0];
423 } elseif (count($parameters) === 2) {
424 $other = $parameters[0] . ' and ' . $parameters[1];
425 } else {
426 $last = array_pop($parameters);
427 $other = 'all ' . implode(', ', $parameters) . ' and ' . $last;
428 }
429
430 // Default message
431 $text = 'The :attribute field is required when :other field(s) are all missing.';
432
433 return str_replace(
434 [':attribute', ':other'],
435 [$attribute, $other],
436 $text
437 );
438 }
439
440 /**
441 * Replace placeholders in a validation message for required array keys.
442 *
443 * @param string $attribute
444 * @param array $parameters
445 * @param string $originalKey
446 *
447 * @return string
448 */
449 protected function replaceRequiredArrayKeys(
450 $attribute,
451 $parameters,
452 $originalKey
453 )
454 {
455 if (preg_match('/\.\d\./', $attribute, $matches)) {
456 $parameters[0] = str_replace(['.*.'], $matches, $parameters[0]);
457 }
458
459 $text = $this->getReplacementText($attribute.'.required_array_keys', 'required_array_keys', $originalKey);
460
461 $other = '';
462
463 if (count($parameters) === 1) {
464 $other = $parameters[0] . ' key';
465 } elseif (count($parameters) === 2) {
466 $other = $parameters[0] . ' and ' . $parameters[1] . ' keys';
467 } else {
468 $last = array_pop($parameters);
469 $other = 'all ' . implode(', ', $parameters) . ' and ' . $last . ' keys';
470 }
471
472 return str_replace(
473 [':attribute', ':keys'],
474 [$attribute, $other],
475 $text
476 );
477 }
478
479 /**
480 * Replace all place-holders for the gt rule.
481 *
482 * @param $attribute
483 * @param $parameters
484 * @param $originalKey
485 *
486 * @return string
487 */
488 protected function replaceGt($attribute, $parameters, $originalKey)
489 {
490 if (preg_match('/\.\d\./', $attribute, $matches)) {
491 $parameters[0] = str_replace(['.*.'], $matches, $parameters[0]);
492 }
493
494 $text = $this->getReplacementText($attribute.'.gt', 'gt', $originalKey);
495
496 $value = end($parameters);
497
498 return str_replace([
499 ':attribute', ':value'],
500 [$attribute, $value],
501 $text
502 );
503 }
504
505 /**
506 * Replace all place-holders for the lt rule.
507 *
508 * @param $attribute
509 * @param $parameters
510 * @param $originalKey
511 *
512 * @return string
513 */
514 protected function replaceLt($attribute, $parameters, $originalKey)
515 {
516 if (preg_match('/\.\d\./', $attribute, $matches)) {
517 $parameters[0] = str_replace(['.*.'], $matches, $parameters[0]);
518 }
519
520 $text = $this->getReplacementText($attribute.'.lt', 'lt', $originalKey);
521
522 $value = end($parameters);
523
524 return str_replace([
525 ':attribute', ':value'],
526 [$attribute, $value],
527 $text
528 );
529 }
530
531 /**
532 * Replace all place-holders for the gte rule.
533 *
534 * @param $attribute
535 * @param $parameters
536 * @param $originalKey
537 *
538 * @return string
539 */
540 protected function replaceGte($attribute, $parameters, $originalKey)
541 {
542 if (preg_match('/\.\d\./', $attribute, $matches)) {
543 $parameters[0] = str_replace(['.*.'], $matches, $parameters[0]);
544 }
545
546 $text = $this->getReplacementText($attribute.'.gte', 'gte', $originalKey);
547
548 $value = end($parameters);
549
550 return str_replace([
551 ':attribute', ':value'],
552 [$attribute, $value],
553 $text
554 );
555 }
556
557 /**
558 * Replace all place-holders for the lte rule.
559 *
560 * @param $attribute
561 * @param $parameters
562 * @param $originalKey
563 *
564 * @return string
565 */
566 protected function replaceLte($attribute, $parameters, $originalKey)
567 {
568 if (preg_match('/\.\d\./', $attribute, $matches)) {
569 $parameters[0] = str_replace(['.*.'], $matches, $parameters[0]);
570 }
571
572 $text = $this->getReplacementText($attribute.'.lte', 'lte', $originalKey);
573
574 $value = end($parameters);
575
576 return str_replace([
577 ':attribute', ':value'],
578 [$attribute, $value],
579 $text
580 );
581 }
582
583 /**
584 * Replace all place-holders for the email rule.
585 *
586 * @param $attribute
587 * @param $parameters
588 * @param $originalKey
589 *
590 * @return string
591 */
592 protected function replaceEmail($attribute, $parameters, $originalKey)
593 {
594 $text = $this->getReplacementText(
595 $attribute.'.email', 'email', $originalKey
596 );
597
598 return str_replace(':attribute', $attribute, $text);
599 }
600
601 /**
602 * Replace all place-holders for the email rule.
603 *
604 * @param $attribute
605 * @param $parameters
606 * @param $originalKey
607 *
608 * @return string
609 */
610 protected function replaceDateformat($attribute, $parameters, $originalKey)
611 {
612 $text = $this->getReplacementText($attribute.'.date_format', 'date_format', $$originalKey);
613
614 return str_replace(
615 [':attribute', ':value'], [$attribute, $parameters[0]], $text
616 );
617 }
618
619 /**
620 * Replace all place-holders for the size rule.
621 *
622 * @param $attribute
623 * @param $parameters
624 * @param $originalKey
625 *
626 * @return string
627 */
628 protected function replaceSize($attribute, $parameters, $originalKey)
629 {
630 $text = $this->getReplacementText($attribute.'.size', $this->makeBagKey($attribute, 'size'), $originalKey);
631
632 return str_replace(
633 [':attribute', ':size'], [$attribute, $parameters[0]], $text
634 );
635 }
636
637 /**
638 * Replace all place-holders for the min rule.
639 *
640 * @param $attribute
641 * @param $parameters
642 * @param $originalKey
643 *
644 * @return string
645 */
646 protected function replaceMin($attribute, $parameters, $originalKey)
647 {
648 $text = $this->getReplacementText($attribute.'.min', $this->makeBagKey($attribute, 'min'), $originalKey);
649
650 return str_replace(
651 [':attribute', ':min'], [$attribute, $parameters[0]], $text
652 );
653 }
654
655 /**
656 * Replace all place-holders for the max rule.
657 *
658 * @param $attribute
659 * @param $parameters
660 * @param $originalKey
661 *
662 * @return string
663 */
664 protected function replaceMax($attribute, $parameters, $originalKey)
665 {
666 $text = $this->getReplacementText($attribute.'.max', $this->makeBagKey($attribute, 'max'), $originalKey);
667
668 return str_replace(
669 [':attribute', ':max'], [$attribute, $parameters[0]], $text
670 );
671 }
672
673 /**
674 * Replace all place-holders for the min rule.
675 *
676 * @param $attribute
677 * @param $parameters
678 * @param $originalKey
679 *
680 * @return string
681 */
682 protected function replaceSame($attribute, $parameters, $originalKey)
683 {
684 $text = $this->getReplacementText($attribute.'.same', 'same', $originalKey);
685
686 return str_replace(
687 [':attribute', ':other'], [$attribute, $parameters[0]], $text
688 );
689 }
690
691 /**
692 * Replace all place-holders for the url rule.
693 *
694 * @param $attribute
695 * @param $parameters
696 * @param $originalKey
697 *
698 * @return string
699 */
700 protected function replaceUrl($attribute, $parameters, $originalKey)
701 {
702 $text = $this->getReplacementText($attribute.'.url', 'url', $originalKey);
703
704 return str_replace(':attribute', $attribute, $text);
705 }
706
707 /**
708 * Replace all place-holders for the numeric rule.
709 *
710 * @param $attribute
711 * @param $parameters
712 * @param $originalKey
713 *
714 * @return string
715 */
716 protected function replaceNumeric($attribute, $parameters, $originalKey)
717 {
718 $text = $this->getReplacementText($attribute.'.numeric', 'numeric', $originalKey);
719
720 return str_replace(':attribute', $attribute, $text);
721 }
722
723 /**
724 * Replace all place-holders for the mimes rule.
725 *
726 * @param $attribute
727 * @param $parameters
728 * @param $originalKey
729 *
730 * @return string
731 */
732 protected function replaceMimes($attribute, $parameters, $originalKey)
733 {
734 $text = $this->getReplacementText($attribute.'.mimes', 'mimes', $originalKey);
735
736 return str_replace([':attribute', ':values'], [$attribute, implode(', ', $parameters)], $text);
737 }
738
739 /**
740 * Replace all place-holders for the mimetypes rule.
741 *
742 * @param $attribute
743 * @param $parameters
744 * @param $originalKey
745 *
746 * @return string
747 */
748 protected function replaceMimetypes($attribute, $parameters, $originalKey)
749 {
750 $text = $this->getReplacementText($attribute.'.mimetypes', 'mimetypes', $originalKey);
751
752 return str_replace([':attribute', ':values'], [$attribute, implode(', ', $parameters)], $text);
753 }
754
755 /**
756 * Replace all place-holders for the unique rule.
757 *
758 * @param $attribute
759 * @param $parameters
760 * @param $originalKey
761 *
762 * @return string
763 */
764 protected function replaceUnique($attribute, $parameters, $originalKey)
765 {
766 $text = $this->getReplacementText($attribute.'.unique', 'unique', $originalKey);
767
768 return str_replace(':attribute', $attribute, $text);
769 }
770
771 /**
772 * Replace all place-holders for the digits rule.
773 *
774 * @param $attribute
775 * @param $parameters
776 * @param $originalKey
777 *
778 * @return string
779 */
780 protected function replaceDigits($attribute, $parameters, $originalKey)
781 {
782 $text = $this->getReplacementText($attribute.'.digits', 'digits', $originalKey);
783
784 return str_replace([':attribute', ':digits'], [$attribute, $parameters[0]], $text);
785 }
786
787 /**
788 * Replace all place-holders for the array rule.
789 *
790 * @param $attribute
791 * @param $parameters
792 * @param $originalKey
793 *
794 * @return string
795 */
796 protected function replaceArray($attribute, $parameters, $originalKey)
797 {
798 $text = $this->getReplacementText($attribute.'.array', 'array', $originalKey);
799
800 return str_replace([':attribute', ':array'], [$attribute], $text);
801 }
802
803 /**
804 * Replace all place-holders for the in rule.
805 *
806 * @param $attribute
807 * @param $parameters
808 * @param $originalKey
809 *
810 * @return string
811 */
812 protected function replaceIn($attribute, $parameters, $originalKey)
813 {
814 $text = $this->getReplacementText($attribute.'.in', 'in', $originalKey);
815
816 return str_replace([':attribute', ':in'], [$attribute], $text);
817 }
818
819 /**
820 * Replace all place-holders for the not_in rule.
821 *
822 * @param $attribute
823 * @param $parameters
824 * @param $originalKey
825 *
826 * @return string
827 */
828 protected function replaceNotIn($attribute, $parameters, $originalKey)
829 {
830 $text = $this->getReplacementText($attribute.'.not_in', 'not_in', $originalKey);
831
832 return str_replace([':attribute', ':not_in'], [$attribute], $text);
833 }
834
835 /**
836 * Replace all place-holders for the exista rule.
837 *
838 * @param $attribute
839 * @param $parameters
840 * @param $originalKey
841 *
842 * @return string
843 */
844 protected function replaceExists($attribute, $parameters, $originalKey)
845 {
846 $text = $this->getReplacementText($attribute.'.exists', 'exists', $originalKey);
847
848 return str_replace([':attribute', ':exists'], [$attribute], $text);
849 }
850 }
851