Skip to content

Commit

Permalink
Fix default values
Browse files Browse the repository at this point in the history
  • Loading branch information
romanmatyus committed Oct 6, 2018
1 parent 37a7933 commit 76506f2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/RM/SMSender/EuroSms/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
class Message extends SMSender\Message implements SMSender\IMessage
{

public function setFrom(string $from) : SMSender\IMessage
public function setFrom(string $from = '') : SMSender\IMessage
{
if (!Strings::match($from, '~^[0-9a-zA-Z\. -]{1,14}$~'))
throw new InvalidArgumentException('Parameter "from" can contain only alphanumerical character, space, "-" and "." and must have from 1-14 characters.');
return parent::setFrom($from);
}

public function setTo(string $number) : SMSender\IMessage
public function setTo(string $number = '') : SMSender\IMessage
{
if (!Strings::match($number, '~^09\d{8}|\+?\d{12}$~'))
throw new InvalidArgumentException('Parameter "number" can use number in formats "09xxYYYYYY" or "+xxxYYYzzzzzz".');
return parent::setTo($number);
}

public function setText(string $text) : SMSender\IMessage
public function setText(string $text = '') : SMSender\IMessage
{
if (strlen($text) < 1 OR strlen($text) > 160)
throw new InvalidArgumentException('Parameter "text" must be length 1-160 characters. Has ' . strlen($text) . ' characters.');
Expand Down
6 changes: 3 additions & 3 deletions src/RM/SMSender/IMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

interface IMessage
{
public function setFrom(string $from) : IMessage;
public function setFrom(string $from = '') : IMessage;

public function setTo(string $number) : IMessage;
public function setTo(string $number = '') : IMessage;

public function setText(string $text) : IMessage;
public function setText(string $text = '') : IMessage;

public function getFrom() : string;

Expand Down
12 changes: 6 additions & 6 deletions src/RM/SMSender/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ class Message implements IMessage
/** @var string */
protected $text = '';

public function setFrom(string $from = NULL) : IMessage
public function setFrom(string $from = '') : IMessage
{
$this->from = (string) $from;
$this->from = $from;
return $this;
}

public function setTo(string $number = NULL) : IMessage
public function setTo(string $number = '') : IMessage
{
$this->to = (string) $number;
$this->to = $number;
return $this;
}

public function setText(string $text = NULL) : IMessage
public function setText(string $text = '') : IMessage
{
$this->text = (string) $text;
$this->text = $text;
return $this;
}

Expand Down

0 comments on commit 76506f2

Please sign in to comment.