Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

sample of refactor for fluent interface

  • Loading branch information...
commit 3cc58ffb6897194aab856b7694ab17d0470bb477 1 parent 315f0f0
@cordoval cordoval authored iampersistent committed
Showing with 38 additions and 0 deletions.
  1. +38 −0 lib/Vespolina/Entity/CreditCardProfile.php
View
38 lib/Vespolina/Entity/CreditCardProfile.php
@@ -18,23 +18,42 @@
protected $expiration;
protected $persistedCardNumber;
+ /**
+ * @param string $address
+ * @return $this
+ */
public function setAddress($address)
{
$this->address = $address;
+
+ return $this;
}
+ /**
+ * @return mixed
+ */
public function getAddress()
{
return $this->address;
}
+ /**
+ * @param string $cardNumber
+ * @return $this
+ */
public function setCardNumber($cardNumber)
{
$this->activeCardNumber = preg_replace('/\D/', '', $cardNumber);
$chars = strlen($this->activeCardNumber);
$this->persistedCardNumber = str_repeat('*', $chars - 4) . substr($this->activeCardNumber, -4);
+
+ return $this;
}
+ /**
+ * @param null $type
+ * @return mixed
+ */
public function getCardNumber($type = null)
{
if ($type === 'active') {
@@ -43,21 +62,40 @@ public function getCardNumber($type = null)
return $this->persistedCardNumber;
}
+ /**
+ * @param $cardType
+ * @return $this
+ */
public function setCardType($cardType)
{
$this->cardType = $cardType;
+
+ return $this;
}
+ /**
+ * @return mixed
+ */
public function getCardType()
{
return $this->cardType;
}
+ /**
+ * @param $month
+ * @param $year
+ * @return $this
+ */
public function setExpiration($month, $year)
{
$this->expiration = array('month' => $month, 'year' => $year);
+
+ return $this;
}
+ /**
+ * @return mixed
+ */
public function getExpiration()
{
return $this->expiration;
Please sign in to comment.
Something went wrong with that request. Please try again.