Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Aug 16, 2016
1 parent 6dbd1a1 commit 551c9c3
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 104 deletions.
109 changes: 43 additions & 66 deletions src/LobAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,43 @@

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')
{
return new static($line1, $country);
}

/**
* @param $line1
* @param null $name
* @param string $line1
* @param string $country
*/
public function __construct($line1, $country = 'US')
{
Expand All @@ -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;
}
Expand All @@ -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,
]);
}
}
7 changes: 1 addition & 6 deletions src/LobChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@

class LobChannel
{
/**
* The Lob library instance.
*
* @var \Lob\Lob
*/
/** @var \Lob\Lob */
protected $lob;

/**
Expand All @@ -38,7 +34,6 @@ public function send($notifiable, Notification $notification)
$messageContent['to'] = $address;
}


$this->lob->{$message->type}()->create($messageContent);
}
}
63 changes: 31 additions & 32 deletions src/LobPostcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -57,6 +54,7 @@ public function fromAddress($value)

/**
* @param string|LobAddress $value
*
* @return $this
*/
public function toAddress($value)
Expand All @@ -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()
Expand All @@ -111,7 +111,6 @@ public function size4x6()
}

/**
* @param mixed $value
* @return $this
*/
public function size6x11()
Expand Down
12 changes: 12 additions & 0 deletions tests/ChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 551c9c3

Please sign in to comment.