Skip to content

Commit b1399d3

Browse files
authored
Added validation logic for e164 (#521)
1 parent 394213c commit b1399d3

31 files changed

+173
-13
lines changed

src/Messages/Channel/MMS/MMSAudio.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class MMSAudio extends BaseMessage
1212

1313
protected string $channel = 'mms';
1414
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_AUDIO;
15+
protected bool $validatesE164 = true;
1516

1617
public function __construct(
1718
string $to,
@@ -22,6 +23,11 @@ public function __construct(
2223
$this->from = $from;
2324
}
2425

26+
public function validatesE164(): bool
27+
{
28+
return $this->validatesE164;
29+
}
30+
2531
public function toArray(): array
2632
{
2733
$returnArray = $this->getBaseMessageUniversalOutputArray();

src/Messages/Channel/MMS/MMSImage.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class MMSImage extends BaseMessage
1212

1313
protected string $channel = 'mms';
1414
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_IMAGE;
15+
protected bool $validatesE164 = true;
1516

1617
public function __construct(
1718
string $to,
@@ -22,6 +23,11 @@ public function __construct(
2223
$this->from = $from;
2324
}
2425

26+
public function validatesE164(): bool
27+
{
28+
return $this->validatesE164;
29+
}
30+
2531
public function toArray(): array
2632
{
2733
$returnArray = $this->getBaseMessageUniversalOutputArray();

src/Messages/Channel/MMS/MMSVideo.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class MMSVideo extends BaseMessage
1313

1414
protected string $channel = 'mms';
1515
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_VIDEO;
16+
protected bool $validatesE164 = true;
1617

1718
public function __construct(
1819
string $to,
@@ -23,6 +24,11 @@ public function __construct(
2324
$this->from = $from;
2425
}
2526

27+
public function validatesE164(): bool
28+
{
29+
return $this->validatesE164;
30+
}
31+
2632
public function toArray(): array
2733
{
2834
$returnArray = $this->getBaseMessageUniversalOutputArray();

src/Messages/Channel/MMS/MMSvCard.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class MMSvCard extends BaseMessage
1212

1313
protected string $channel = 'mms';
1414
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_VCARD;
15+
protected bool $validatesE164 = true;
1516

1617
public function __construct(
1718
string $to,
@@ -22,6 +23,11 @@ public function __construct(
2223
$this->from = $from;
2324
}
2425

26+
public function validatesE164(): bool
27+
{
28+
return $this->validatesE164;
29+
}
30+
2531
public function toArray(): array
2632
{
2733
$returnArray = $this->getBaseMessageUniversalOutputArray();

src/Messages/Channel/Message.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function getWebhookUrl(): ?string;
1919
public function setWebhookUrl(string $url): void;
2020
public function getWebhookVersion(): ?string;
2121
public function setWebhookVersion(string $version): void;
22+
public function validatesE164(): bool;
2223

2324
/**
2425
* All message types have shared outputs required by the endpoint.

src/Messages/Channel/Messenger/MessengerAudio.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class MessengerAudio extends BaseMessage
1111

1212
protected string $channel = 'messenger';
1313
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_AUDIO;
14+
protected bool $validatesE164 = false;
1415

1516
public function __construct(
1617
string $to,
@@ -25,6 +26,11 @@ public function __construct(
2526
$this->tag = $tag;
2627
}
2728

29+
public function validatesE164(): bool
30+
{
31+
return $this->validatesE164;
32+
}
33+
2834
public function toArray(): array
2935
{
3036
$returnArray = $this->getBaseMessageUniversalOutputArray();

src/Messages/Channel/Messenger/MessengerFile.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class MessengerFile extends BaseMessage
1111

1212
protected string $channel = 'messenger';
1313
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_FILE;
14+
protected bool $validatesE164 = false;
1415

1516
public function __construct(
1617
string $to,
@@ -36,4 +37,9 @@ public function toArray(): array
3637

3738
return $returnArray;
3839
}
40+
41+
public function validatesE164(): bool
42+
{
43+
return $this->validatesE164;
44+
}
3945
}

src/Messages/Channel/Messenger/MessengerImage.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class MessengerImage extends BaseMessage
1111

1212
protected string $channel = 'messenger';
1313
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_IMAGE;
14+
protected bool $validatesE164 = false;
1415

1516
public function __construct(
1617
string $to,
@@ -36,4 +37,9 @@ public function toArray(): array
3637

3738
return $returnArray;
3839
}
40+
41+
public function validatesE164(): bool
42+
{
43+
return $this->validatesE164;
44+
}
3945
}

src/Messages/Channel/Messenger/MessengerObjectTrait.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@ trait MessengerObjectTrait
77
private ?string $category;
88
private ?string $tag;
99

10-
/**
11-
* @return string
12-
*/
1310
public function getCategory(): ?string
1411
{
1512
return $this->category;
1613
}
1714

18-
1915
public function requiresMessengerObject(): bool
2016
{
2117
return $this->getTag() || $this->getCategory();
@@ -26,9 +22,6 @@ public function setCategory(string $category): void
2622
$this->category = $category;
2723
}
2824

29-
/**
30-
* @return string
31-
*/
3225
public function getTag(): ?string
3326
{
3427
return $this->tag;

src/Messages/Channel/Messenger/MessengerText.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class MessengerText extends BaseMessage
1212

1313
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_TEXT;
1414
protected string $channel = 'messenger';
15+
protected bool $validatesE164 = false;
1516

1617
public function __construct(
1718
string $to,
@@ -27,6 +28,11 @@ public function __construct(
2728
$this->tag = $tag;
2829
}
2930

31+
public function validatesE164(): bool
32+
{
33+
return $this->validatesE164;
34+
}
35+
3036
public function toArray(): array
3137
{
3238
$returnArray = $this->getBaseMessageUniversalOutputArray();

0 commit comments

Comments
 (0)