From cf8bf684754b41b3c08de0c61b128f908c346e0c Mon Sep 17 00:00:00 2001 From: Michael V Date: Sat, 2 Feb 2019 14:01:21 +0100 Subject: [PATCH] Improve docblocks, fix spelling --- src/Cart.php | 59 +++++++++++++++++++++++---------------------- src/CartItem.php | 62 ++++++++++++++++++++++++------------------------ 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/src/Cart.php b/src/Cart.php index 995158b7..21b62e9c 100644 --- a/src/Cart.php +++ b/src/Cart.php @@ -3,6 +3,7 @@ namespace Gloudemans\Shoppingcart; use Closure; +use Illuminate\Database\Connection; use Illuminate\Support\Collection; use Illuminate\Session\SessionManager; use Illuminate\Database\DatabaseManager; @@ -22,14 +23,14 @@ class Cart /** * Instance of the session manager. * - * @var \Illuminate\Session\SessionManager + * @var SessionManager */ private $session; /** * Instance of the event dispatcher. * - * @var \Illuminate\Contracts\Events\Dispatcher + * @var Dispatcher */ private $events; @@ -50,8 +51,8 @@ class Cart /** * Cart constructor. * - * @param \Illuminate\Session\SessionManager $session - * @param \Illuminate\Contracts\Events\Dispatcher $events + * @param SessionManager $session + * @param Dispatcher $events */ public function __construct(SessionManager $session, Dispatcher $events) { @@ -66,7 +67,7 @@ public function __construct(SessionManager $session, Dispatcher $events) * Set the current cart instance. * * @param string|null $instance - * @return \Gloudemans\Shoppingcart\Cart + * @return Cart */ public function instance($instance = null) { @@ -95,7 +96,7 @@ public function currentInstance() * @param int|float $qty * @param float $price * @param array $options - * @return \Gloudemans\Shoppingcart\CartItem + * @return CartItem */ public function add($id, $name = null, $qty = null, $price = null, array $options = []) { @@ -125,8 +126,8 @@ public function add($id, $name = null, $qty = null, $price = null, array $option /** * Sets/adds an additional cost on the cart. * - * @param $type - * @param $price + * @param string $name + * @param float $price * @todo add in session */ public function addCost($name, $price) @@ -142,14 +143,14 @@ public function addCost($name, $price) * @param $name * @param int|null $decimals * @param string|null $decimalPoint - * @param string|null $thousandSeperator + * @param string|null $thousandSeparator * @return string */ - public function getCost($name, $decimals = null, $decimalPoint = null, $thousandSeperator = null) + public function getCost($name, $decimals = null, $decimalPoint = null, $thousandSeparator = null) { $cost = $this->extraCosts->get($name, 0); - return $this->numberFormat($cost, $decimals, $decimalPoint, $thousandSeperator); + return $this->numberFormat($cost, $decimals, $decimalPoint, $thousandSeparator); } /** @@ -157,7 +158,7 @@ public function getCost($name, $decimals = null, $decimalPoint = null, $thousand * * @param string $rowId * @param mixed $qty - * @return \Gloudemans\Shoppingcart\CartItem + * @return CartItem */ public function update($rowId, $qty) { @@ -219,7 +220,7 @@ public function remove($rowId) * Get a cart item from the cart by its rowId. * * @param string $rowId - * @return \Gloudemans\Shoppingcart\CartItem + * @return CartItem */ public function get($rowId) { @@ -272,10 +273,10 @@ public function count() * * @param int $decimals * @param string $decimalPoint - * @param string $thousandSeperator + * @param string $thousandSeparator * @return string */ - public function total($decimals = null, $decimalPoint = null, $thousandSeperator = null) + public function total($decimals = null, $decimalPoint = null, $thousandSeparator = null) { $content = $this->getContent(); @@ -289,7 +290,7 @@ public function total($decimals = null, $decimalPoint = null, $thousandSeperator $total += $totalCost; - return $this->numberFormat($total, $decimals, $decimalPoint, $thousandSeperator); + return $this->numberFormat($total, $decimals, $decimalPoint, $thousandSeparator); } /** @@ -297,10 +298,10 @@ public function total($decimals = null, $decimalPoint = null, $thousandSeperator * * @param int $decimals * @param string $decimalPoint - * @param string $thousandSeperator + * @param string $thousandSeparator * @return float */ - public function tax($decimals = null, $decimalPoint = null, $thousandSeperator = null) + public function tax($decimals = null, $decimalPoint = null, $thousandSeparator = null) { $content = $this->getContent(); @@ -308,7 +309,7 @@ public function tax($decimals = null, $decimalPoint = null, $thousandSeperator = return $tax + ($cartItem->qty * $cartItem->tax); }, 0); - return $this->numberFormat($tax, $decimals, $decimalPoint, $thousandSeperator); + return $this->numberFormat($tax, $decimals, $decimalPoint, $thousandSeparator); } /** @@ -316,10 +317,10 @@ public function tax($decimals = null, $decimalPoint = null, $thousandSeperator = * * @param int $decimals * @param string $decimalPoint - * @param string $thousandSeperator + * @param string $thousandSeparator * @return float */ - public function subtotal($decimals = null, $decimalPoint = null, $thousandSeperator = null) + public function subtotal($decimals = null, $decimalPoint = null, $thousandSeparator = null) { $content = $this->getContent(); @@ -327,7 +328,7 @@ public function subtotal($decimals = null, $decimalPoint = null, $thousandSepera return $subTotal + ($cartItem->qty * $cartItem->price); }, 0); - return $this->numberFormat($subTotal, $decimals, $decimalPoint, $thousandSeperator); + return $this->numberFormat($subTotal, $decimals, $decimalPoint, $thousandSeparator); } /** @@ -492,7 +493,7 @@ protected function getContent() * @param int|float $qty * @param float $price * @param array $options - * @return \Gloudemans\Shoppingcart\CartItem + * @return CartItem */ private function createCartItem($id, $name, $qty, $price, array $options) { @@ -538,7 +539,7 @@ private function storedCartWithIdentifierExists($identifier) /** * Get the database connection. * - * @return \Illuminate\Database\Connection + * @return Connection */ private function getConnection() { @@ -575,10 +576,10 @@ private function getConnectionName() * @param $value * @param $decimals * @param $decimalPoint - * @param $thousandSeperator + * @param $thousandSeparator * @return string */ - private function numberFormat($value, $decimals, $decimalPoint, $thousandSeperator) + private function numberFormat($value, $decimals, $decimalPoint, $thousandSeparator) { if(is_null($decimals)){ $decimals = is_null(config('cart.format.decimals')) ? 2 : config('cart.format.decimals'); @@ -586,10 +587,10 @@ private function numberFormat($value, $decimals, $decimalPoint, $thousandSeperat if(is_null($decimalPoint)){ $decimalPoint = is_null(config('cart.format.decimal_point')) ? '.' : config('cart.format.decimal_point'); } - if(is_null($thousandSeperator)){ - $thousandSeperator = is_null(config('cart.format.thousand_seperator')) ? ',' : config('cart.format.thousand_seperator'); + if(is_null($thousandSeparator)){ + $thousandSeparator = is_null(config('cart.format.thousand_seperator')) ? ',' : config('cart.format.thousand_seperator'); } - return number_format($value, $decimals, $decimalPoint, $thousandSeperator); + return number_format($value, $decimals, $decimalPoint, $thousandSeparator); } } diff --git a/src/CartItem.php b/src/CartItem.php index bb9442c4..ac1b0df4 100644 --- a/src/CartItem.php +++ b/src/CartItem.php @@ -96,12 +96,12 @@ public function __construct($id, $name, $price, array $options = []) * * @param int $decimals * @param string $decimalPoint - * @param string $thousandSeperator + * @param string $thousandSeparator * @return string */ - public function price($decimals = null, $decimalPoint = null, $thousandSeperator = null) + public function price($decimals = null, $decimalPoint = null, $thousandSeparator = null) { - return $this->numberFormat($this->price, $decimals, $decimalPoint, $thousandSeperator); + return $this->numberFormat($this->price, $decimals, $decimalPoint, $thousandSeparator); } /** @@ -109,12 +109,12 @@ public function price($decimals = null, $decimalPoint = null, $thousandSeperator * * @param int $decimals * @param string $decimalPoint - * @param string $thousandSeperator + * @param string $thousandSeparator * @return string */ - public function priceTax($decimals = null, $decimalPoint = null, $thousandSeperator = null) + public function priceTax($decimals = null, $decimalPoint = null, $thousandSeparator = null) { - return $this->numberFormat($this->priceTax, $decimals, $decimalPoint, $thousandSeperator); + return $this->numberFormat($this->priceTax, $decimals, $decimalPoint, $thousandSeparator); } /** @@ -123,12 +123,12 @@ public function priceTax($decimals = null, $decimalPoint = null, $thousandSepera * * @param int $decimals * @param string $decimalPoint - * @param string $thousandSeperator + * @param string $thousandSeparator * @return string */ - public function subtotal($decimals = null, $decimalPoint = null, $thousandSeperator = null) + public function subtotal($decimals = null, $decimalPoint = null, $thousandSeparator = null) { - return $this->numberFormat($this->subtotal, $decimals, $decimalPoint, $thousandSeperator); + return $this->numberFormat($this->subtotal, $decimals, $decimalPoint, $thousandSeparator); } /** @@ -137,12 +137,12 @@ public function subtotal($decimals = null, $decimalPoint = null, $thousandSepera * * @param int $decimals * @param string $decimalPoint - * @param string $thousandSeperator + * @param string $thousandSeparator * @return string */ - public function total($decimals = null, $decimalPoint = null, $thousandSeperator = null) + public function total($decimals = null, $decimalPoint = null, $thousandSeparator = null) { - return $this->numberFormat($this->total, $decimals, $decimalPoint, $thousandSeperator); + return $this->numberFormat($this->total, $decimals, $decimalPoint, $thousandSeparator); } /** @@ -150,12 +150,12 @@ public function total($decimals = null, $decimalPoint = null, $thousandSeperator * * @param int $decimals * @param string $decimalPoint - * @param string $thousandSeperator + * @param string $thousandSeparator * @return string */ - public function tax($decimals = null, $decimalPoint = null, $thousandSeperator = null) + public function tax($decimals = null, $decimalPoint = null, $thousandSeparator = null) { - return $this->numberFormat($this->tax, $decimals, $decimalPoint, $thousandSeperator); + return $this->numberFormat($this->tax, $decimals, $decimalPoint, $thousandSeparator); } /** @@ -163,12 +163,12 @@ public function tax($decimals = null, $decimalPoint = null, $thousandSeperator = * * @param int $decimals * @param string $decimalPoint - * @param string $thousandSeperator + * @param string $thousandSeparator * @return string */ - public function taxTotal($decimals = null, $decimalPoint = null, $thousandSeperator = null) + public function taxTotal($decimals = null, $decimalPoint = null, $thousandSeparator = null) { - return $this->numberFormat($this->taxTotal, $decimals, $decimalPoint, $thousandSeperator); + return $this->numberFormat($this->taxTotal, $decimals, $decimalPoint, $thousandSeparator); } /** @@ -187,7 +187,7 @@ public function setQuantity($qty) /** * Update the cart item from a Buyable. * - * @param \Gloudemans\Shoppingcart\Contracts\Buyable $item + * @param Buyable $item * @return void */ public function updateFromBuyable(Buyable $item) @@ -220,7 +220,7 @@ public function updateFromArray(array $attributes) * Associate the cart item with the given model. * * @param mixed $model - * @return \Gloudemans\Shoppingcart\CartItem + * @return CartItem */ public function associate($model) { @@ -233,7 +233,7 @@ public function associate($model) * Set the tax rate. * * @param int|float $taxRate - * @return \Gloudemans\Shoppingcart\CartItem + * @return CartItem */ public function setTaxRate($taxRate) { @@ -284,9 +284,9 @@ public function __get($attribute) /** * Create a new instance from a Buyable. * - * @param \Gloudemans\Shoppingcart\Contracts\Buyable $item - * @param array $options - * @return \Gloudemans\Shoppingcart\CartItem + * @param Buyable $item + * @param array $options + * @return CartItem */ public static function fromBuyable(Buyable $item, array $options = []) { @@ -297,7 +297,7 @@ public static function fromBuyable(Buyable $item, array $options = []) * Create a new instance from the given array. * * @param array $attributes - * @return \Gloudemans\Shoppingcart\CartItem + * @return CartItem */ public static function fromArray(array $attributes) { @@ -313,7 +313,7 @@ public static function fromArray(array $attributes) * @param string $name * @param float $price * @param array $options - * @return \Gloudemans\Shoppingcart\CartItem + * @return CartItem */ public static function fromAttributes($id, $name, $price, array $options = []) { @@ -370,10 +370,10 @@ public function toJson($options = 0) * @param float $value * @param int $decimals * @param string $decimalPoint - * @param string $thousandSeperator + * @param string $thousandSeparator * @return string */ - private function numberFormat($value, $decimals = null, $decimalPoint = null, $thousandSeperator = null) + private function numberFormat($value, $decimals = null, $decimalPoint = null, $thousandSeparator = null) { if (is_null($decimals)){ $decimals = is_null(config('cart.format.decimals')) ? 2 : config('cart.format.decimals'); @@ -383,10 +383,10 @@ private function numberFormat($value, $decimals = null, $decimalPoint = null, $t $decimalPoint = is_null(config('cart.format.decimal_point')) ? '.' : config('cart.format.decimal_point'); } - if (is_null($thousandSeperator)){ - $thousandSeperator = is_null(config('cart.format.thousand_seperator')) ? ',' : config('cart.format.thousand_seperator'); + if (is_null($thousandSeparator)){ + $thousandSeparator = is_null(config('cart.format.thousand_seperator')) ? ',' : config('cart.format.thousand_seperator'); } - return number_format($value, $decimals, $decimalPoint, $thousandSeperator); + return number_format($value, $decimals, $decimalPoint, $thousandSeparator); } }