44
55namespace Kerox \Fcm \Helper ;
66
7- use InvalidArgumentException ;
8-
97trait ValidatorTrait
108{
119 /**
@@ -15,7 +13,7 @@ public function isValidData(array $data): void
1513 {
1614 foreach ($ data as $ key => $ value ) {
1715 if (!\is_string ($ key ) || !\is_string ($ value )) {
18- throw new InvalidArgumentException ('Array must only contain string for key and value. ' );
16+ throw new \ InvalidArgumentException ('Array must only contain string for key and value. ' );
1917 }
2018 }
2119 }
@@ -26,7 +24,7 @@ public function isValidData(array $data): void
2624 public function isValidTtl (string $ ttl ): void
2725 {
2826 if (!preg_match ('/^\d+(\.\d{1,9})?s$/ ' , $ ttl )) {
29- throw new InvalidArgumentException ('Invalid TTL format. ' );
27+ throw new \ InvalidArgumentException ('Invalid TTL format. ' );
3028 }
3129 }
3230
@@ -36,7 +34,7 @@ public function isValidTtl(string $ttl): void
3634 public function isValidLang (string $ lang ): void
3735 {
3836 if (!preg_match ('/^[a-z]{2}-[A-Z]{2}$/ ' , $ lang )) {
39- throw new InvalidArgumentException ('Invalid lang format. ' );
37+ throw new \ InvalidArgumentException ('Invalid lang format. ' );
4038 }
4139 }
4240
@@ -47,7 +45,7 @@ public function isValidVibratePattern(array $vibratePattern): void
4745 {
4846 foreach ($ vibratePattern as $ pattern ) {
4947 if (!\is_int ($ pattern )) {
50- throw new InvalidArgumentException ('Vibrate pattern must only contain integer. ' );
48+ throw new \ InvalidArgumentException ('Vibrate pattern must only contain integer. ' );
5149 }
5250 }
5351 }
@@ -61,7 +59,7 @@ protected function isValidUrl(string $url): void
6159 '/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/=]*)$/ ' ,
6260 $ url
6361 )) {
64- throw new InvalidArgumentException (sprintf ('%s is not a valid url. ' , $ url ));
62+ throw new \ InvalidArgumentException (sprintf ('"%s" is not a valid url. ' , $ url ));
6563 }
6664 }
6765
@@ -71,7 +69,7 @@ protected function isValidUrl(string $url): void
7169 public function isValidTopicName (string $ topic ): void
7270 {
7371 if (!preg_match ('/^[a-zA-Z0-9-_.~%]+$/ ' , $ topic )) {
74- throw new InvalidArgumentException (sprintf ('%s is an invalid topic name. ' , $ topic ));
72+ throw new \ InvalidArgumentException (sprintf ('"%s" is an invalid topic name. ' , $ topic ));
7573 }
7674 }
7775}
0 commit comments