-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Notifier] Add SMS options to Esendex notifier
- Loading branch information
1 parent
0d2dc15
commit 3adb4c6
Showing
5 changed files
with
118 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
CHANGELOG | ||
========= | ||
|
||
6.3 | ||
--- | ||
|
||
* Add `EsendexOptions` class | ||
|
||
6.2 | ||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Notifier\Bridge\Esendex; | ||
|
||
use Symfony\Component\Notifier\Message\MessageOptionsInterface; | ||
|
||
/** | ||
* @author gnito-org <https://github.com/gnito-org> | ||
*/ | ||
final class EsendexOptions implements MessageOptionsInterface | ||
{ | ||
private array $options; | ||
|
||
public function __construct(array $options = []) | ||
{ | ||
$this->options = $options; | ||
} | ||
|
||
public function getAccountReference(): ?string | ||
{ | ||
return $this->options['account_reference'] ?? null; | ||
} | ||
|
||
public function getFrom(): ?string | ||
{ | ||
return $this->options['from'] ?? null; | ||
} | ||
|
||
public function getRecipientId(): ?string | ||
{ | ||
return $this->options['recipient_id'] ?? null; | ||
} | ||
|
||
public function setAccountReference(string $accountReference): self | ||
{ | ||
$this->options['account_reference'] = $accountReference; | ||
|
||
return $this; | ||
} | ||
|
||
public function setFrom(string $from): self | ||
{ | ||
$this->options['from'] = $from; | ||
|
||
return $this; | ||
} | ||
|
||
public function setRecipientId(string $id): self | ||
{ | ||
$this->options['recipient_id'] = $id; | ||
|
||
return $this; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
$options = $this->options; | ||
if (isset($options['recipient_id'])) { | ||
unset($options['recipient_id']); | ||
} | ||
|
||
return $options; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Notifier\Bridge\Esendex\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Notifier\Bridge\Esendex\EsendexOptions; | ||
|
||
class EsendexOptionsTest extends TestCase | ||
{ | ||
public function testEsendexOptions() | ||
{ | ||
$esendexOptions = (new EsendexOptions())->setFrom('test_from')->setAccountReference('test_account_reference')->setRecipientId('test_recipient'); | ||
|
||
self::assertSame([ | ||
'from' => 'test_from', | ||
'account_reference' => 'test_account_reference', | ||
], $esendexOptions->toArray()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters