File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ CHANGELOG
55---
66
77 * Add PHPUnit constraints
8+ * Add ` from ` property in ` SmsMessage `
89
9106.1
1011---
Original file line number Diff line number Diff line change @@ -23,15 +23,17 @@ class SmsMessage implements MessageInterface
2323 private ?string $ transport = null ;
2424 private string $ subject ;
2525 private string $ phone ;
26+ private string $ from ;
2627
27- public function __construct (string $ phone , string $ subject )
28+ public function __construct (string $ phone , string $ subject, string $ from = '' )
2829 {
2930 if ('' === $ phone ) {
3031 throw new InvalidArgumentException (sprintf ('"%s" needs a phone number, it cannot be empty. ' , __CLASS__ ));
3132 }
3233
3334 $ this ->subject = $ subject ;
3435 $ this ->phone = $ phone ;
36+ $ this ->from = $ from ;
3537 }
3638
3739 public static function fromNotification (Notification $ notification , SmsRecipientInterface $ recipient ): self
@@ -93,6 +95,21 @@ public function getTransport(): ?string
9395 return $ this ->transport ;
9496 }
9597
98+ /**
99+ * @return $this
100+ */
101+ public function from (string $ from ): static
102+ {
103+ $ this ->from = $ from ;
104+
105+ return $ this ;
106+ }
107+
108+ public function getFrom (): string
109+ {
110+ return $ this ->from ;
111+ }
112+
96113 public function getOptions (): ?MessageOptionsInterface
97114 {
98115 return null ;
Original file line number Diff line number Diff line change @@ -25,6 +25,16 @@ public function testCanBeConstructed()
2525
2626 $ this ->assertSame ('subject ' , $ message ->getSubject ());
2727 $ this ->assertSame ('+3312345678 ' , $ message ->getPhone ());
28+ $ this ->assertSame ('' , $ message ->getFrom ());
29+ }
30+
31+ public function testCanBeConstructedWithFrom ()
32+ {
33+ $ message = new SmsMessage ('+3312345678 ' , 'subject ' , 'foo ' );
34+
35+ $ this ->assertSame ('subject ' , $ message ->getSubject ());
36+ $ this ->assertSame ('+3312345678 ' , $ message ->getPhone ());
37+ $ this ->assertSame ('foo ' , $ message ->getFrom ());
2838 }
2939
3040 public function testEnsureNonEmptyPhoneOnConstruction ()
@@ -57,4 +67,15 @@ public function testEnsureNonEmptyPhoneOnSet()
5767
5868 $ message ->phone ('' );
5969 }
70+
71+ public function testSetFrom ()
72+ {
73+ $ message = new SmsMessage ('+3312345678 ' , 'subject ' );
74+
75+ $ this ->assertSame ('' , $ message ->getFrom ());
76+
77+ $ message ->from ('foo ' );
78+
79+ $ this ->assertSame ('foo ' , $ message ->getFrom ());
80+ }
6081}
You can’t perform that action at this time.
0 commit comments