diff --git a/src/LobAddress.php b/src/LobAddress.php index 8d92857..da4ce26 100644 --- a/src/LobAddress.php +++ b/src/LobAddress.php @@ -4,46 +4,34 @@ class LobAddress { - /** - * @var string - */ + /** @var string */ protected $line1 = 'postcards'; - /** - * @var string - */ + /** @var string */ protected $line2; - /** - * @var string - */ + /** @var string */ protected $country; - /** - * @var string - */ + /** @var string */ protected $city; - /** - * @var string - */ + /** @var string */ protected $state; - /** - * @var string - */ + /** @var string */ protected $zip; - /** - * @var string - */ + /** @var string */ protected $name = 'name'; /** - * @param string $body + * @param string $line1 + * @param string $country * * @return static + * */ public static function create($line1, $country = 'US') { @@ -51,8 +39,8 @@ public static function create($line1, $country = 'US') } /** - * @param $line1 - * @param null $name + * @param string $line1 + * @param string $country */ public function __construct($line1, $country = 'US') { @@ -62,67 +50,73 @@ public function __construct($line1, $country = 'US') } /** - * @param mixed $value + * @param string $line2 + * * @return $this */ - public function line2($value) + public function line2($line2) { - $this->line2 = $value; + $this->line2 = $line2; return $this; } /** - * @param mixed $value + * @param string $country + * * @return $this */ - public function country($value) + public function country($country) { - $this->country = $value; + $this->country = $country; return $this; } /** - * @param mixed $value + * @param string $city + * * @return $this */ - public function city($value) + public function city($city) { - $this->city = $value; + $this->city = $city; return $this; } /** - * @param mixed $value + * @param string $state + * * @return $this */ - public function state($value) + public function state($state) { - $this->state = $value; + $this->state = $state; return $this; } /** - * @param mixed $value + * @param string $zip + * * @return $this */ - public function zip($value) + public function zip($zip) { - $this->zip = $value; + $this->zip = $zip; return $this; } /** - * @param mixed $value + * @param string $name + * * @return $this */ - public function name($value) + public function name($name) { - $this->name = $value; + $this->name = $name; return $this; } @@ -134,31 +128,14 @@ public function name($value) */ public function toArray() { - $output = [ + return array_filter([ 'address_line1' => $this->line1, 'address_country' => $this->country, - ]; - - if ($this->line2) { - $output['address_line2'] = $this->line2; - } - - if ($this->city) { - $output['address_city'] = $this->city; - } - - if ($this->state) { - $output['address_state'] = $this->state; - } - - if ($this->zip) { - $output['address_zip'] = $this->zip; - } - - if ($this->name) { - $output['name'] = $this->name; - } - - return $output; + 'address_line2' => $this->line2, + 'address_city' => $this->city, + 'address_state' => $this->state, + 'address_zip' => $this->zip, + 'name' => $this->name, + ]); } } diff --git a/src/LobChannel.php b/src/LobChannel.php index d5cd164..8bc3863 100644 --- a/src/LobChannel.php +++ b/src/LobChannel.php @@ -7,11 +7,7 @@ class LobChannel { - /** - * The Lob library instance. - * - * @var \Lob\Lob - */ + /** @var \Lob\Lob */ protected $lob; /** @@ -38,7 +34,6 @@ public function send($notifiable, Notification $notification) $messageContent['to'] = $address; } - $this->lob->{$message->type}()->create($messageContent); } } diff --git a/src/LobPostcard.php b/src/LobPostcard.php index 09d6699..093285a 100644 --- a/src/LobPostcard.php +++ b/src/LobPostcard.php @@ -4,48 +4,45 @@ class LobPostcard { - /** - * @var string - */ + /** @var string */ public $type = 'postcards'; - /** - * @var string|null - */ + /** @var string|null */ protected $fromAddress = null; - /** - * @var string|null - */ + /** @var string|null */ protected $toAddress = null; - /** - * @var string - */ + /** @var string */ protected $front; - /** - * @var string - */ + /** @var string */ protected $message; - /** - * @var string - */ + /** @var string */ protected $size = '4x6'; /** - * @param string $body + * @param string $message * * @return static */ - public static function create() + public static function create($message = '') + { + return new static($message); + } + + /** + * @param string $message + */ + public function __construct($message = '') { - return new static(); + $this->message = $message; } /** * @param string|LobAddress $value + * * @return $this */ public function fromAddress($value) @@ -57,6 +54,7 @@ public function fromAddress($value) /** * @param string|LobAddress $value + * * @return $this */ public function toAddress($value) @@ -67,40 +65,42 @@ public function toAddress($value) } /** - * @param mixed $value + * @param mixed $front + * * @return $this */ - public function front($value) + public function front($front) { - $this->front = $value; + $this->front = $front; return $this; } /** - * @param mixed $value + * @param string $message + * * @return $this */ - public function message($value) + public function message($message) { - $this->message = $value; + $this->message = $message; return $this; } /** - * @param mixed $value + * @param string $size + * * @return $this */ - public function size($value) + public function size($size) { - $this->size = $value; + $this->size = $size; return $this; } /** - * @param mixed $value * @return $this */ public function size4x6() @@ -111,7 +111,6 @@ public function size4x6() } /** - * @param mixed $value * @return $this */ public function size6x11() diff --git a/tests/ChannelTest.php b/tests/ChannelTest.php index a3fb3a1..93392b6 100644 --- a/tests/ChannelTest.php +++ b/tests/ChannelTest.php @@ -13,8 +13,20 @@ class ChannelTest extends PHPUnit_Framework_TestCase { + /** @var \Lob\Lob|Mockery\Mock */ + protected $lobClient; + + /** @var \NotificationChannels\Lob\LobChannel */ + protected $channel; + + + protected $notification; + + public function setUp() { + parent::setUp(); + $this->lobClient = Mockery::mock(Lob::class); $this->channel = new LobChannel($this->lobClient);