Skip to content

Commit 3c390f1

Browse files
Merge pull request #51 from happypixels/laravel-7
Laravel 7 support & StyleCI fixes
2 parents 8cc3992 + 3a7a5f3 commit 3c390f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+90
-90
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"league/omnipay": "^3",
1414
"omnipay/stripe": "3.1.x-dev#37df2a791e8feab45543125f4c5f22d5d305096d",
1515
"moneyphp/money": "^3.1",
16-
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0"
16+
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0"
1717
},
1818
"require-dev": {
1919
"vlucas/phpdotenv": "^2.4",

src/Cart/Cart.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Happypixels\Shopr\Cart;
44

5-
use Illuminate\Support\Collection;
5+
use Happypixels\Shopr\Contracts\Shoppable;
66
use Happypixels\Shopr\Models\Order;
77
use Happypixels\Shopr\Money\Formatter;
8-
use Happypixels\Shopr\Contracts\Shoppable;
8+
use Illuminate\Support\Collection;
99

1010
abstract class Cart
1111
{
@@ -28,7 +28,7 @@ abstract public function persist($data);
2828
*
2929
* @return Collection
3030
*/
31-
public function getAllItems() : Collection
31+
public function getAllItems(): Collection
3232
{
3333
return collect($this->get());
3434
}
@@ -38,7 +38,7 @@ public function getAllItems() : Collection
3838
*
3939
* @return Collection
4040
*/
41-
public function items() : Collection
41+
public function items(): Collection
4242
{
4343
return $this->getAllItems()->filter(function ($item) {
4444
return $item->shoppable->isDiscount() === false;
@@ -50,7 +50,7 @@ public function items() : Collection
5050
*
5151
* @return Collection
5252
*/
53-
public function discounts() : Collection
53+
public function discounts(): Collection
5454
{
5555
return $this->getAllItems()->filter(function ($item) {
5656
return $item->shoppable->isDiscount() === true;
@@ -62,7 +62,7 @@ public function discounts() : Collection
6262
*
6363
* @return Collection
6464
*/
65-
public function relativeDiscounts() : Collection
65+
public function relativeDiscounts(): Collection
6666
{
6767
return $this->discounts()->filter(function ($discount) {
6868
return ! $discount->shoppable->is_fixed;
@@ -203,7 +203,7 @@ public function addDiscount(Shoppable $coupon)
203203
* @param string $code
204204
* @return bool
205205
*/
206-
public function hasDiscount($code = null) : bool
206+
public function hasDiscount($code = null): bool
207207
{
208208
foreach ($this->discounts() as $item) {
209209
if (! $code) {
@@ -290,7 +290,7 @@ public function convertToOrder($gateway, $data = [])
290290
* @param float|null $price
291291
* @return Happypixels\Shopr\Cart\CartItem
292292
*/
293-
public function addItem($shoppableType, $shoppableId, $quantity = 1, $options = [], $subItems = [], $price = null) : CartItem
293+
public function addItem($shoppableType, $shoppableId, $quantity = 1, $options = [], $subItems = [], $price = null): CartItem
294294
{
295295
$quantity = (is_numeric($quantity) && $quantity > 0) ? $quantity : 1;
296296

src/Contracts/Shoppable.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ public function getTitle();
1010

1111
public function getPrice();
1212

13-
public function isDiscount() : bool;
13+
public function isDiscount(): bool;
1414
}

src/Controllers/CartDiscountController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Happypixels\Shopr\Controllers;
44

5-
use Illuminate\Http\Request;
65
use Happypixels\Shopr\Cart\Cart;
7-
use Illuminate\Routing\Controller;
86
use Happypixels\Shopr\Models\DiscountCoupon;
97
use Illuminate\Foundation\Validation\ValidatesRequests;
8+
use Illuminate\Http\Request;
9+
use Illuminate\Routing\Controller;
1010

1111
class CartDiscountController extends Controller
1212
{

src/Controllers/CartItemController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Happypixels\Shopr\Controllers;
44

5-
use Illuminate\Http\Request;
65
use Happypixels\Shopr\Cart\Cart;
7-
use Illuminate\Routing\Controller;
86
use Happypixels\Shopr\Rules\Discounts\NotADiscount;
97
use Illuminate\Foundation\Validation\ValidatesRequests;
8+
use Illuminate\Http\Request;
9+
use Illuminate\Routing\Controller;
1010

1111
class CartItemController extends Controller
1212
{

src/Controllers/CheckoutController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Happypixels\Shopr\Controllers;
44

5-
use Illuminate\Http\Request;
65
use Happypixels\Shopr\Cart\Cart;
7-
use Illuminate\Routing\Controller;
86
use Happypixels\Shopr\PaymentProviders\PaymentProviderManager;
7+
use Illuminate\Http\Request;
8+
use Illuminate\Routing\Controller;
99

1010
class CheckoutController extends Controller
1111
{

src/Controllers/Web/OrderController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Happypixels\Shopr\Controllers\Web;
44

5-
use Illuminate\Routing\Controller;
65
use Happypixels\Shopr\Models\Order;
6+
use Illuminate\Routing\Controller;
77

88
class OrderController extends Controller
99
{

src/Controllers/Web/PaymentConfirmationController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Happypixels\Shopr\Controllers\Web;
44

5-
use Illuminate\Http\Request;
6-
use Illuminate\Routing\Controller;
7-
use Happypixels\Shopr\Models\Order;
85
use Happypixels\Shopr\Exceptions\PaymentFailedException;
6+
use Happypixels\Shopr\Models\Order;
97
use Happypixels\Shopr\PaymentProviders\PaymentProviderManager;
8+
use Illuminate\Http\Request;
9+
use Illuminate\Routing\Controller;
1010

1111
class PaymentConfirmationController extends Controller
1212
{

src/Mails/OrderCreatedAdmins.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Happypixels\Shopr\Mails;
44

5+
use Happypixels\Shopr\Models\Order;
56
use Illuminate\Bus\Queueable;
67
use Illuminate\Mail\Mailable;
7-
use Happypixels\Shopr\Models\Order;
88
use Illuminate\Queue\SerializesModels;
99

1010
class OrderCreatedAdmins extends Mailable

src/Mails/OrderCreatedCustomer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Happypixels\Shopr\Mails;
44

5+
use Happypixels\Shopr\Models\Order;
56
use Illuminate\Bus\Queueable;
67
use Illuminate\Mail\Mailable;
7-
use Happypixels\Shopr\Models\Order;
88
use Illuminate\Queue\SerializesModels;
99

1010
class OrderCreatedCustomer extends Mailable

src/Models/DiscountCoupon.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getCalculatedPositiveValue()
8383
*
8484
* @return bool
8585
*/
86-
public function isDiscount() : bool
86+
public function isDiscount(): bool
8787
{
8888
return true;
8989
}

src/Models/Shoppable.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Happypixels\Shopr\Models;
44

5-
use Illuminate\Database\Eloquent\Model;
65
use Happypixels\Shopr\Contracts\Shoppable as ShoppableContract;
6+
use Illuminate\Database\Eloquent\Model;
77

88
class Shoppable extends Model implements ShoppableContract
99
{
@@ -42,7 +42,7 @@ public function getPrice()
4242
*
4343
* @return bool
4444
*/
45-
public function isDiscount() : bool
45+
public function isDiscount(): bool
4646
{
4747
return false;
4848
}

src/Money/Formatter.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Happypixels\Shopr\Money;
44

5-
use Money\Money;
6-
use Money\Currency;
7-
use NumberFormatter;
85
use Money\Currencies\ISOCurrencies;
6+
use Money\Currency;
97
use Money\Formatter\IntlMoneyFormatter;
8+
use Money\Money;
9+
use NumberFormatter;
1010

1111
class Formatter
1212
{

src/Observers/OrderObserver.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace Happypixels\Shopr\Observers;
44

55
use Happypixels\Shopr\Cart\Cart;
6-
use Happypixels\Shopr\Models\Order;
7-
use Illuminate\Support\Facades\Mail;
86
use Happypixels\Shopr\Mails\OrderCreatedAdmins;
97
use Happypixels\Shopr\Mails\OrderCreatedCustomer;
8+
use Happypixels\Shopr\Models\Order;
9+
use Illuminate\Support\Facades\Mail;
1010

1111
class OrderObserver
1212
{

src/PaymentProviders/PaymentProvider.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace Happypixels\Shopr\PaymentProviders;
44

5-
use Omnipay\Omnipay;
6-
use Illuminate\Support\Str;
7-
use Illuminate\Http\Request;
85
use Happypixels\Shopr\Cart\Cart;
9-
use Happypixels\Shopr\Models\Order;
106
use Happypixels\Shopr\Exceptions\PaymentFailedException;
7+
use Happypixels\Shopr\Models\Order;
8+
use Illuminate\Http\Request;
9+
use Illuminate\Support\Str;
10+
use Omnipay\Omnipay;
1111

1212
abstract class PaymentProvider
1313
{
@@ -35,7 +35,7 @@ abstract public function purchase();
3535
*
3636
* @return array
3737
*/
38-
abstract public function getPaymentConfirmationData() : array;
38+
abstract public function getPaymentConfirmationData(): array;
3939

4040
/**
4141
* Makes the purchase and returns the results if successful. Throws exception if unsuccessful.

src/PaymentProviders/PaymentProviderManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Happypixels\Shopr\PaymentProviders;
44

5-
use Illuminate\Http\Request;
65
use Happypixels\Shopr\Exceptions\InvalidGatewayException;
6+
use Illuminate\Http\Request;
77

88
class PaymentProviderManager
99
{

src/PaymentProviders/Stripe.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function purchase()
2828
*
2929
* @return array
3030
*/
31-
public function getPaymentConfirmationData() : array
31+
public function getPaymentConfirmationData(): array
3232
{
3333
return [
3434
'paymentIntentReference' => $this->input['payment_intent'],

src/Rules/Discounts/CartValueAboveCouponLimit.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Happypixels\Shopr\Rules\Discounts;
44

55
use Happypixels\Shopr\Cart\Cart;
6-
use Illuminate\Contracts\Validation\Rule;
76
use Happypixels\Shopr\Models\DiscountCoupon;
7+
use Illuminate\Contracts\Validation\Rule;
88

99
class CartValueAboveCouponLimit implements Rule
1010
{

src/Rules/Discounts/CouponExists.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Happypixels\Shopr\Rules\Discounts;
44

5-
use Illuminate\Contracts\Validation\Rule;
65
use Happypixels\Shopr\Models\DiscountCoupon;
6+
use Illuminate\Contracts\Validation\Rule;
77

88
class CouponExists implements Rule
99
{

src/Rules/Discounts/DateIsWithinCouponTimespan.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Happypixels\Shopr\Rules\Discounts;
44

5-
use Illuminate\Contracts\Validation\Rule;
65
use Happypixels\Shopr\Models\DiscountCoupon;
6+
use Illuminate\Contracts\Validation\Rule;
77

88
class DateIsWithinCouponTimespan implements Rule
99
{

src/ShoprServiceProvider.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
namespace Happypixels\Shopr;
44

55
use Happypixels\Shopr\Cart\Cart;
6+
use Happypixels\Shopr\Cart\Drivers\SessionCart;
67
use Happypixels\Shopr\Models\Order;
7-
use Illuminate\Support\Facades\Event;
8-
use Happypixels\Shopr\Money\Formatter;
98
use Happypixels\Shopr\Models\OrderItem;
10-
use Illuminate\Support\ServiceProvider;
9+
use Happypixels\Shopr\Money\Formatter;
1110
use Happypixels\Shopr\Observers\OrderObserver;
12-
use Happypixels\Shopr\Cart\Drivers\SessionCart;
11+
use Illuminate\Support\Facades\Event;
12+
use Illuminate\Support\ServiceProvider;
1313

1414
class ShoprServiceProvider extends ServiceProvider
1515
{

tests/Feature/Cart/AddCartItemTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Happypixels\Shopr\Tests\Feature\Cart;
44

55
use Happypixels\Shopr\Cart\Cart;
6-
use Happypixels\Shopr\Tests\TestCase;
76
use Happypixels\Shopr\Models\DiscountCoupon;
7+
use Happypixels\Shopr\Tests\TestCase;
88

99
class AddCartItemTest extends TestCase
1010
{
@@ -35,9 +35,9 @@ public function discounts_are_not_allowed()
3535
public function it_throws_404_error_if_shoppable_is_not_found()
3636
{
3737
$this->json('POST', 'api/shopr/cart/items', [
38-
'shoppable_id' => 2,
39-
'shoppable_type' => 'Happypixels\Shopr\Tests\Support\Models\TestShoppable',
40-
])
38+
'shoppable_id' => 2,
39+
'shoppable_type' => 'Happypixels\Shopr\Tests\Support\Models\TestShoppable',
40+
])
4141
->assertStatus(404);
4242
}
4343

tests/Feature/Cart/CartControllerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
namespace Happypixels\Shopr\Tests\Feature\Cart;
44

55
use Happypixels\Shopr\Cart\Cart;
6+
use Happypixels\Shopr\Tests\Support\Models\TestShoppable;
67
use Happypixels\Shopr\Tests\TestCase;
78
use Illuminate\Support\Facades\Event;
8-
use Happypixels\Shopr\Tests\Support\Models\TestShoppable;
99

1010
class CartControllerTest extends TestCase
1111
{

tests/Feature/Cart/RemoveCartItemTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace Happypixels\Shopr\Tests\Feature\Cart;
44

55
use Happypixels\Shopr\Cart\Cart;
6-
use Happypixels\Shopr\Tests\TestCase;
7-
use Illuminate\Support\Facades\Event;
86
use Happypixels\Shopr\Models\DiscountCoupon;
97
use Happypixels\Shopr\Tests\Support\Models\TestShoppable;
8+
use Happypixels\Shopr\Tests\TestCase;
9+
use Illuminate\Support\Facades\Event;
1010

1111
class RemoveCartItemTest extends TestCase
1212
{

tests/Feature/Cart/UpdateCartItemTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace Happypixels\Shopr\Tests\Feature\Cart;
44

55
use Happypixels\Shopr\Cart\Cart;
6-
use Happypixels\Shopr\Tests\TestCase;
7-
use Illuminate\Support\Facades\Event;
86
use Happypixels\Shopr\Models\DiscountCoupon;
97
use Happypixels\Shopr\Tests\Support\Models\TestShoppable;
8+
use Happypixels\Shopr\Tests\TestCase;
9+
use Illuminate\Support\Facades\Event;
1010

1111
class UpdateCartItemTest extends TestCase
1212
{

tests/Feature/Mails/OrderCreatedAdminsMailTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
namespace Happypixels\Shopr\Tests\Feature\Mails;
44

55
use Happypixels\Shopr\Cart\Cart;
6-
use Illuminate\Support\Facades\Mail;
7-
use Happypixels\Shopr\Tests\TestCase;
8-
use Illuminate\Support\Facades\Event;
96
use Happypixels\Shopr\Mails\OrderCreatedAdmins;
10-
use Illuminate\Foundation\Testing\RefreshDatabase;
117
use Happypixels\Shopr\Tests\Support\Models\TestShoppable;
8+
use Happypixels\Shopr\Tests\TestCase;
9+
use Illuminate\Foundation\Testing\RefreshDatabase;
10+
use Illuminate\Support\Facades\Event;
11+
use Illuminate\Support\Facades\Mail;
1212

1313
class OrderCreatedAdminsMailTest extends TestCase
1414
{

0 commit comments

Comments
 (0)