Skip to content

Commit

Permalink
Merge pull request #51 from happypixels/laravel-7
Browse files Browse the repository at this point in the history
Laravel 7 support & StyleCI fixes
  • Loading branch information
mattias-persson committed Apr 11, 2020
2 parents 8cc3992 + 3a7a5f3 commit 3c390f1
Show file tree
Hide file tree
Showing 46 changed files with 90 additions and 90 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"league/omnipay": "^3",
"omnipay/stripe": "3.1.x-dev#37df2a791e8feab45543125f4c5f22d5d305096d",
"moneyphp/money": "^3.1",
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0"
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0"
},
"require-dev": {
"vlucas/phpdotenv": "^2.4",
Expand Down
16 changes: 8 additions & 8 deletions src/Cart/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Happypixels\Shopr\Cart;

use Illuminate\Support\Collection;
use Happypixels\Shopr\Contracts\Shoppable;
use Happypixels\Shopr\Models\Order;
use Happypixels\Shopr\Money\Formatter;
use Happypixels\Shopr\Contracts\Shoppable;
use Illuminate\Support\Collection;

abstract class Cart
{
Expand All @@ -28,7 +28,7 @@ abstract public function persist($data);
*
* @return Collection
*/
public function getAllItems() : Collection
public function getAllItems(): Collection
{
return collect($this->get());
}
Expand All @@ -38,7 +38,7 @@ public function getAllItems() : Collection
*
* @return Collection
*/
public function items() : Collection
public function items(): Collection
{
return $this->getAllItems()->filter(function ($item) {
return $item->shoppable->isDiscount() === false;
Expand All @@ -50,7 +50,7 @@ public function items() : Collection
*
* @return Collection
*/
public function discounts() : Collection
public function discounts(): Collection
{
return $this->getAllItems()->filter(function ($item) {
return $item->shoppable->isDiscount() === true;
Expand All @@ -62,7 +62,7 @@ public function discounts() : Collection
*
* @return Collection
*/
public function relativeDiscounts() : Collection
public function relativeDiscounts(): Collection
{
return $this->discounts()->filter(function ($discount) {
return ! $discount->shoppable->is_fixed;
Expand Down Expand Up @@ -203,7 +203,7 @@ public function addDiscount(Shoppable $coupon)
* @param string $code
* @return bool
*/
public function hasDiscount($code = null) : bool
public function hasDiscount($code = null): bool
{
foreach ($this->discounts() as $item) {
if (! $code) {
Expand Down Expand Up @@ -290,7 +290,7 @@ public function convertToOrder($gateway, $data = [])
* @param float|null $price
* @return Happypixels\Shopr\Cart\CartItem
*/
public function addItem($shoppableType, $shoppableId, $quantity = 1, $options = [], $subItems = [], $price = null) : CartItem
public function addItem($shoppableType, $shoppableId, $quantity = 1, $options = [], $subItems = [], $price = null): CartItem
{
$quantity = (is_numeric($quantity) && $quantity > 0) ? $quantity : 1;

Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/Shoppable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public function getTitle();

public function getPrice();

public function isDiscount() : bool;
public function isDiscount(): bool;
}
4 changes: 2 additions & 2 deletions src/Controllers/CartDiscountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Happypixels\Shopr\Controllers;

use Illuminate\Http\Request;
use Happypixels\Shopr\Cart\Cart;
use Illuminate\Routing\Controller;
use Happypixels\Shopr\Models\DiscountCoupon;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class CartDiscountController extends Controller
{
Expand Down
4 changes: 2 additions & 2 deletions src/Controllers/CartItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Happypixels\Shopr\Controllers;

use Illuminate\Http\Request;
use Happypixels\Shopr\Cart\Cart;
use Illuminate\Routing\Controller;
use Happypixels\Shopr\Rules\Discounts\NotADiscount;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class CartItemController extends Controller
{
Expand Down
4 changes: 2 additions & 2 deletions src/Controllers/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Happypixels\Shopr\Controllers;

use Illuminate\Http\Request;
use Happypixels\Shopr\Cart\Cart;
use Illuminate\Routing\Controller;
use Happypixels\Shopr\PaymentProviders\PaymentProviderManager;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class CheckoutController extends Controller
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Web/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Happypixels\Shopr\Controllers\Web;

use Illuminate\Routing\Controller;
use Happypixels\Shopr\Models\Order;
use Illuminate\Routing\Controller;

class OrderController extends Controller
{
Expand Down
6 changes: 3 additions & 3 deletions src/Controllers/Web/PaymentConfirmationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Happypixels\Shopr\Controllers\Web;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Happypixels\Shopr\Models\Order;
use Happypixels\Shopr\Exceptions\PaymentFailedException;
use Happypixels\Shopr\Models\Order;
use Happypixels\Shopr\PaymentProviders\PaymentProviderManager;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class PaymentConfirmationController extends Controller
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mails/OrderCreatedAdmins.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Happypixels\Shopr\Mails;

use Happypixels\Shopr\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Happypixels\Shopr\Models\Order;
use Illuminate\Queue\SerializesModels;

class OrderCreatedAdmins extends Mailable
Expand Down
2 changes: 1 addition & 1 deletion src/Mails/OrderCreatedCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Happypixels\Shopr\Mails;

use Happypixels\Shopr\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Happypixels\Shopr\Models\Order;
use Illuminate\Queue\SerializesModels;

class OrderCreatedCustomer extends Mailable
Expand Down
2 changes: 1 addition & 1 deletion src/Models/DiscountCoupon.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function getCalculatedPositiveValue()
*
* @return bool
*/
public function isDiscount() : bool
public function isDiscount(): bool
{
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Shoppable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Happypixels\Shopr\Models;

use Illuminate\Database\Eloquent\Model;
use Happypixels\Shopr\Contracts\Shoppable as ShoppableContract;
use Illuminate\Database\Eloquent\Model;

class Shoppable extends Model implements ShoppableContract
{
Expand Down Expand Up @@ -42,7 +42,7 @@ public function getPrice()
*
* @return bool
*/
public function isDiscount() : bool
public function isDiscount(): bool
{
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Money/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Happypixels\Shopr\Money;

use Money\Money;
use Money\Currency;
use NumberFormatter;
use Money\Currencies\ISOCurrencies;
use Money\Currency;
use Money\Formatter\IntlMoneyFormatter;
use Money\Money;
use NumberFormatter;

class Formatter
{
Expand Down
4 changes: 2 additions & 2 deletions src/Observers/OrderObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Happypixels\Shopr\Observers;

use Happypixels\Shopr\Cart\Cart;
use Happypixels\Shopr\Models\Order;
use Illuminate\Support\Facades\Mail;
use Happypixels\Shopr\Mails\OrderCreatedAdmins;
use Happypixels\Shopr\Mails\OrderCreatedCustomer;
use Happypixels\Shopr\Models\Order;
use Illuminate\Support\Facades\Mail;

class OrderObserver
{
Expand Down
10 changes: 5 additions & 5 deletions src/PaymentProviders/PaymentProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Happypixels\Shopr\PaymentProviders;

use Omnipay\Omnipay;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Happypixels\Shopr\Cart\Cart;
use Happypixels\Shopr\Models\Order;
use Happypixels\Shopr\Exceptions\PaymentFailedException;
use Happypixels\Shopr\Models\Order;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Omnipay\Omnipay;

abstract class PaymentProvider
{
Expand Down Expand Up @@ -35,7 +35,7 @@ abstract public function purchase();
*
* @return array
*/
abstract public function getPaymentConfirmationData() : array;
abstract public function getPaymentConfirmationData(): array;

/**
* Makes the purchase and returns the results if successful. Throws exception if unsuccessful.
Expand Down
2 changes: 1 addition & 1 deletion src/PaymentProviders/PaymentProviderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Happypixels\Shopr\PaymentProviders;

use Illuminate\Http\Request;
use Happypixels\Shopr\Exceptions\InvalidGatewayException;
use Illuminate\Http\Request;

class PaymentProviderManager
{
Expand Down
2 changes: 1 addition & 1 deletion src/PaymentProviders/Stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function purchase()
*
* @return array
*/
public function getPaymentConfirmationData() : array
public function getPaymentConfirmationData(): array
{
return [
'paymentIntentReference' => $this->input['payment_intent'],
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/Discounts/CartValueAboveCouponLimit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Happypixels\Shopr\Rules\Discounts;

use Happypixels\Shopr\Cart\Cart;
use Illuminate\Contracts\Validation\Rule;
use Happypixels\Shopr\Models\DiscountCoupon;
use Illuminate\Contracts\Validation\Rule;

class CartValueAboveCouponLimit implements Rule
{
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/Discounts/CouponExists.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Happypixels\Shopr\Rules\Discounts;

use Illuminate\Contracts\Validation\Rule;
use Happypixels\Shopr\Models\DiscountCoupon;
use Illuminate\Contracts\Validation\Rule;

class CouponExists implements Rule
{
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/Discounts/DateIsWithinCouponTimespan.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Happypixels\Shopr\Rules\Discounts;

use Illuminate\Contracts\Validation\Rule;
use Happypixels\Shopr\Models\DiscountCoupon;
use Illuminate\Contracts\Validation\Rule;

class DateIsWithinCouponTimespan implements Rule
{
Expand Down
8 changes: 4 additions & 4 deletions src/ShoprServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Happypixels\Shopr;

use Happypixels\Shopr\Cart\Cart;
use Happypixels\Shopr\Cart\Drivers\SessionCart;
use Happypixels\Shopr\Models\Order;
use Illuminate\Support\Facades\Event;
use Happypixels\Shopr\Money\Formatter;
use Happypixels\Shopr\Models\OrderItem;
use Illuminate\Support\ServiceProvider;
use Happypixels\Shopr\Money\Formatter;
use Happypixels\Shopr\Observers\OrderObserver;
use Happypixels\Shopr\Cart\Drivers\SessionCart;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;

class ShoprServiceProvider extends ServiceProvider
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Feature/Cart/AddCartItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Happypixels\Shopr\Tests\Feature\Cart;

use Happypixels\Shopr\Cart\Cart;
use Happypixels\Shopr\Tests\TestCase;
use Happypixels\Shopr\Models\DiscountCoupon;
use Happypixels\Shopr\Tests\TestCase;

class AddCartItemTest extends TestCase
{
Expand Down Expand Up @@ -35,9 +35,9 @@ public function discounts_are_not_allowed()
public function it_throws_404_error_if_shoppable_is_not_found()
{
$this->json('POST', 'api/shopr/cart/items', [
'shoppable_id' => 2,
'shoppable_type' => 'Happypixels\Shopr\Tests\Support\Models\TestShoppable',
])
'shoppable_id' => 2,
'shoppable_type' => 'Happypixels\Shopr\Tests\Support\Models\TestShoppable',
])
->assertStatus(404);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Cart/CartControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Happypixels\Shopr\Tests\Feature\Cart;

use Happypixels\Shopr\Cart\Cart;
use Happypixels\Shopr\Tests\Support\Models\TestShoppable;
use Happypixels\Shopr\Tests\TestCase;
use Illuminate\Support\Facades\Event;
use Happypixels\Shopr\Tests\Support\Models\TestShoppable;

class CartControllerTest extends TestCase
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Cart/RemoveCartItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Happypixels\Shopr\Tests\Feature\Cart;

use Happypixels\Shopr\Cart\Cart;
use Happypixels\Shopr\Tests\TestCase;
use Illuminate\Support\Facades\Event;
use Happypixels\Shopr\Models\DiscountCoupon;
use Happypixels\Shopr\Tests\Support\Models\TestShoppable;
use Happypixels\Shopr\Tests\TestCase;
use Illuminate\Support\Facades\Event;

class RemoveCartItemTest extends TestCase
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Cart/UpdateCartItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Happypixels\Shopr\Tests\Feature\Cart;

use Happypixels\Shopr\Cart\Cart;
use Happypixels\Shopr\Tests\TestCase;
use Illuminate\Support\Facades\Event;
use Happypixels\Shopr\Models\DiscountCoupon;
use Happypixels\Shopr\Tests\Support\Models\TestShoppable;
use Happypixels\Shopr\Tests\TestCase;
use Illuminate\Support\Facades\Event;

class UpdateCartItemTest extends TestCase
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Feature/Mails/OrderCreatedAdminsMailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace Happypixels\Shopr\Tests\Feature\Mails;

use Happypixels\Shopr\Cart\Cart;
use Illuminate\Support\Facades\Mail;
use Happypixels\Shopr\Tests\TestCase;
use Illuminate\Support\Facades\Event;
use Happypixels\Shopr\Mails\OrderCreatedAdmins;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Happypixels\Shopr\Tests\Support\Models\TestShoppable;
use Happypixels\Shopr\Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Mail;

class OrderCreatedAdminsMailTest extends TestCase
{
Expand Down
Loading

0 comments on commit 3c390f1

Please sign in to comment.