diff --git a/.gitignore b/.gitignore index 2c1fc0c..38cdbd7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /vendor composer.phar composer.lock -.DS_Store \ No newline at end of file +.DS_Store +.idea \ No newline at end of file diff --git a/composer.json b/composer.json index 3977775..42164ba 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,8 @@ } ], "require": { - "php": ">=5.3.0", - "illuminate/support": "~4" + "php": ">=5.4.0", + "illuminate/support": "~5.0" }, "require-dev": { "mockery/mockery": "0.9.*" diff --git a/src/Gloudemans/Shoppingcart/Cart.php b/src/Gloudemans/Shoppingcart/Cart.php index 37da071..9668f9c 100644 --- a/src/Gloudemans/Shoppingcart/Cart.php +++ b/src/Gloudemans/Shoppingcart/Cart.php @@ -1,5 +1,6 @@ session = $session; $this->event = $event; @@ -96,7 +97,7 @@ class Cart { * @param float $price Price of one item * @param array $options Array of additional options, such as 'size' or 'color' */ - public function add($id, $name = null, $qty = null, $price = null, array $options = array()) + public function add($id, $name = null, $qty = null, $price = null, array $options = []) { // If the first parameter is an array we need to call the add() function again if(is_array($id)) @@ -110,7 +111,7 @@ class Cart { foreach($id as $item) { - $options = array_get($item, 'options', array()); + $options = array_get($item, 'options', []); $this->addRow($item['id'], $item['name'], $item['qty'], $item['price'], $options); } @@ -120,15 +121,15 @@ class Cart { return; } - $options = array_get($id, 'options', array()); + $options = array_get($id, 'options', []); // Fire the cart.add event - $this->event->fire('cart.add', array_merge($id, array('options' => $options))); + $this->event->fire('cart.add', array_merge($id, ['options' => $options])); $result = $this->addRow($id['id'], $id['name'], $id['qty'], $id['price'], $options); // Fire the cart.added event - $this->event->fire('cart.added', array_merge($id, array('options' => $options))); + $this->event->fire('cart.added', array_merge($id, ['options' => $options])); return $result; } @@ -325,7 +326,7 @@ class Cart { * @param float $price Price of one item * @param array $options Array of additional options, such as 'size' or 'color' */ - protected function addRow($id, $name, $qty, $price, array $options = array()) + protected function addRow($id, $name, $qty, $price, array $options = []) { if(empty($id) || empty($name) || empty($qty) || ! isset($price)) { @@ -349,7 +350,7 @@ class Cart { if($cart->has($rowId)) { $row = $cart->get($rowId); - $cart = $this->updateRow($rowId, array('qty' => $row->qty + $qty)); + $cart = $this->updateRow($rowId, ['qty' => $row->qty + $qty]); } else { @@ -443,7 +444,7 @@ class Cart { } } - if( ! is_null(array_keys($attributes, array('qty', 'price')))) + if( ! is_null(array_keys($attributes, ['qty', 'price']))) { $row->put('subtotal', $row->qty * $row->price); } @@ -468,7 +469,7 @@ class Cart { { $cart = $this->getContent(); - $newRow = new CartRowCollection(array( + $newRow = new CartRowCollection([ 'rowid' => $rowId, 'id' => $id, 'name' => $name, @@ -476,7 +477,7 @@ class Cart { 'price' => $price, 'options' => new CartRowOptionsCollection($options), 'subtotal' => $qty * $price - ), $this->associatedModel, $this->associatedModelNamespace); + ], $this->associatedModel, $this->associatedModelNamespace); $cart->put($rowId, $newRow); @@ -497,7 +498,7 @@ class Cart { return $this->remove($rowId); } - return $this->updateRow($rowId, array('qty' => $qty)); + return $this->updateRow($rowId, ['qty' => $qty]); } /** diff --git a/tests/CartTest.php b/tests/CartTest.php index 129e347..940b78e 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -18,7 +18,7 @@ class CartTest extends PHPUnit_Framework_TestCase { public function setUp() { $session= new SessionMock; - $this->events = m::mock('Illuminate\Events\Dispatcher'); + $this->events = m::mock('Illuminate\Contracts\Events\Dispatcher'); $this->cart = new Cart($session, $this->events); }