File tree Expand file tree Collapse file tree 8 files changed +43
-4
lines changed
Expand file tree Collapse file tree 8 files changed +43
-4
lines changed Original file line number Diff line number Diff line change @@ -170,4 +170,13 @@ public function getBaseVerifyUniversalOutputArray(): array
170170
171171 return $ returnArray ;
172172 }
173+
174+ public static function isBrandValid (string $ brand ): bool
175+ {
176+ if (!strlen ($ brand ) < 16 ) {
177+ return true ;
178+ }
179+
180+ return false ;
181+ }
173182}
Original file line number Diff line number Diff line change 22
33namespace Vonage \Verify2 \Request ;
44
5+ use InvalidArgumentException ;
56use Vonage \Verify2 \VerifyObjects \VerificationLocale ;
67use Vonage \Verify2 \VerifyObjects \VerificationWorkflow ;
78
@@ -13,6 +14,10 @@ public function __construct(
1314 protected string $ from ,
1415 protected ?VerificationLocale $ locale = null ,
1516 ) {
17+ if (!self ::isBrandValid ($ this ->brand )) {
18+ throw new InvalidArgumentException ('The brand name cannot be longer than 16 characters. ' );
19+ }
20+
1621 if (!$ this ->locale ) {
1722 $ this ->locale = new VerificationLocale ();
1823 }
Original file line number Diff line number Diff line change 22
33namespace Vonage \Verify2 \Request ;
44
5+ use InvalidArgumentException ;
56use Vonage \Verify2 \VerifyObjects \VerificationLocale ;
67use Vonage \Verify2 \VerifyObjects \VerificationWorkflow ;
78
@@ -15,6 +16,10 @@ public function __construct(
1516 protected string $ entityId = '' ,
1617 protected string $ contentId = ''
1718 ) {
19+ if (!self ::isBrandValid ($ this ->brand )) {
20+ throw new InvalidArgumentException ('The brand name cannot be longer than 16 characters. ' );
21+ }
22+
1823 if (!$ this ->locale ) {
1924 $ this ->locale = new VerificationLocale ();
2025 }
Original file line number Diff line number Diff line change 22
33namespace Vonage \Verify2 \Request ;
44
5+ use InvalidArgumentException ;
56use Vonage \Verify2 \VerifyObjects \VerificationWorkflow ;
67
78class SilentAuthRequest extends BaseVerifyRequest
@@ -11,6 +12,10 @@ public function __construct(
1112 protected string $ brand ,
1213 protected ?string $ redirectUrl = null
1314 ) {
15+ if (!self ::isBrandValid ($ this ->brand )) {
16+ throw new InvalidArgumentException ('The brand name cannot be longer than 16 characters. ' );
17+ }
18+
1419 $ workflow = new VerificationWorkflow (VerificationWorkflow::WORKFLOW_SILENT_AUTH , $ to );
1520
1621 if ($ this ->redirectUrl ) {
Original file line number Diff line number Diff line change 22
33namespace Vonage \Verify2 \Request ;
44
5+ use InvalidArgumentException ;
56use Vonage \Verify2 \VerifyObjects \VerificationLocale ;
67use Vonage \Verify2 \VerifyObjects \VerificationWorkflow ;
78
@@ -12,6 +13,10 @@ public function __construct(
1213 protected string $ brand ,
1314 protected ?VerificationLocale $ locale = null ,
1415 ) {
16+ if (!self ::isBrandValid ($ this ->brand )) {
17+ throw new InvalidArgumentException ('The brand name cannot be longer than 16 characters. ' );
18+ }
19+
1520 if (!$ this ->locale ) {
1621 $ this ->locale = new VerificationLocale ();
1722 }
@@ -29,4 +34,4 @@ public function toArray(): array
2934 {
3035 return $ this ->getBaseVerifyUniversalOutputArray ();
3136 }
32- }
37+ }
Original file line number Diff line number Diff line change 22
33namespace Vonage \Verify2 \Request ;
44
5+ use InvalidArgumentException ;
56use Vonage \Verify2 \VerifyObjects \VerificationLocale ;
67use Vonage \Verify2 \VerifyObjects \VerificationWorkflow ;
78
@@ -12,6 +13,10 @@ public function __construct(
1213 protected string $ brand ,
1314 protected ?VerificationLocale $ locale = null
1415 ) {
16+ if (!self ::isBrandValid ($ this ->brand )) {
17+ throw new InvalidArgumentException ('The brand name cannot be longer than 16 characters. ' );
18+ }
19+
1520 if (!$ this ->locale ) {
1621 $ this ->locale = new VerificationLocale ();
1722 }
@@ -24,4 +29,4 @@ public function toArray(): array
2429 {
2530 return $ this ->getBaseVerifyUniversalOutputArray ();
2631 }
27- }
32+ }
Original file line number Diff line number Diff line change 22
33namespace Vonage \Verify2 \Request ;
44
5+ use InvalidArgumentException ;
56use Vonage \Verify2 \VerifyObjects \VerificationLocale ;
67use Vonage \Verify2 \VerifyObjects \VerificationWorkflow ;
78
@@ -13,6 +14,10 @@ public function __construct(
1314 protected string $ from ,
1415 protected ?VerificationLocale $ locale = null ,
1516 ) {
17+ if (!self ::isBrandValid ($ this ->brand )) {
18+ throw new InvalidArgumentException ('The brand name cannot be longer than 16 characters. ' );
19+ }
20+
1621 if (!$ this ->locale ) {
1722 $ this ->locale = new VerificationLocale ();
1823 }
Original file line number Diff line number Diff line change 88use Laminas \Diactoros \Response ;
99use Prophecy \Argument ;
1010use Prophecy \Prophecy \ObjectProphecy ;
11+ use Vonage \Messages \Channel \Messenger \InvalidCategoryException ;
1112use VonageTest \Traits \Psr7AssertionTrait ;
1213use Vonage \Client ;
1314use Vonage \Client \APIResource ;
@@ -500,8 +501,7 @@ public function testCannotSendConcurrentVerifications(): void
500501
501502 public function testCannotSendWithoutBrand (): void
502503 {
503- $ this ->expectException (Client \Exception \Request::class);
504- $ this ->expectExceptionMessage ('Invalid params: The value of one or more parameters is invalid. See https://www.developer.vonage.com/api-errors#invalid-params for more information ' );
504+ $ this ->expectException (\InvalidArgumentException::class);
505505
506506 $ payload = [
507507 'to ' => '07785254785 ' ,
You can’t perform that action at this time.
0 commit comments