Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Commit

Permalink
mobile connect support
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspijak committed Sep 2, 2021
1 parent cd49d48 commit 97156da
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/Sms/SenderSettings/CountrySenderID.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CountrySenderID
private $iso;

/** @var int */
private $gate = Gate::GATE1;
private $gate;

/** @var string */
private $sender = '';
Expand All @@ -28,18 +28,12 @@ class CountrySenderID
* @param string $iso
* @param int $gate
* @param string $sender
* @throws InvalidGateException
*/
public function __construct(string $iso, int $gate = Gate::GATE1, string $sender = '')
{
$this->iso = strtolower($iso);
$this->gate = $gate;
$this->sender = $sender;

if ((int) $this->gate < Gate::GATE1 || (int) $this->gate > Gate::GATE7)
{
throw new InvalidGateException('Gate must be in interval <0, 6>');
}
}


Expand Down
2 changes: 2 additions & 0 deletions src/Sms/SenderSettings/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class Gate

const GATE_OWN_NUMBER = 'gOwn';

const GATE_MOBILE_CONNECT = 'gMobile';

const GATE1 = 0;

const GATE2 = 1;
Expand Down
10 changes: 10 additions & 0 deletions src/Sms/SenderSettings/StaticSenderSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public function __construct(string $type = Gate::GATE_SYSTEM_NUMBER, string $val
case Gate::GATE_OWN_NUMBER:
$this->ownNumber($value);
break;
case Gate::GATE_MOBILE_CONNECT:
$this->mobileConnect($value);
break;
default:
throw new InvalidSenderException('Unknown sender type '.$type);
break;
Expand Down Expand Up @@ -98,6 +101,13 @@ public function ownNumber(string $value): void
}


public function mobileConnect(string $value): void
{
$this->type = Gate::GATE_MOBILE_CONNECT;
$this->value = $value;
}


/**
* @return array
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/Sms/SenderSettings/CountrySenderID.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Assert::same([
'sender' => '',
], $country->toArray());

Assert::exception(function () {
/*Assert::exception(function () {
new CountrySenderID('CZ', -1, '');
}, InvalidGateException::class, 'Gate must be in interval <0, 6>');
Expand All @@ -40,4 +40,4 @@ Assert::exception(function () {
Assert::exception(function () {
new CountrySenderID('CZ', 125, '');
}, InvalidGateException::class, 'Gate must be in interval <0, 6>');
}, InvalidGateException::class, 'Gate must be in interval <0, 6>');*/

0 comments on commit 97156da

Please sign in to comment.