Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
glennjacobs authored and StyleCIBot committed Feb 11, 2022
1 parent 06a74f5 commit c5edd95
Show file tree
Hide file tree
Showing 74 changed files with 402 additions and 294 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CreateMediaTable extends Migration
{
public function up()
{
if (! Schema::hasTable('media')) {
if (!Schema::hasTable('media')) {
Schema::create('media', function (Blueprint $table) {
$table->bigIncrements('id');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function up()
{
$tableName = config('activitylog.table_name');

if (! Schema::hasTable($tableName)) {
if (!Schema::hasTable($tableName)) {
Schema::create($tableName, function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('log_name')->nullable();
Expand Down
2 changes: 1 addition & 1 deletion database/state/ConvertProductTypeAttributesToProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function run()
{
$prefix = config('getcandy.database.table_prefix');

if (! $this->canRun()) {
if (!$this->canRun()) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions database/state/EnsureDefaultTaxClassExists.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class EnsureDefaultTaxClassExists
{
public function run()
{
if (! $this->canRun() || ! $this->shouldRun()) {
if (!$this->canRun() || !$this->shouldRun()) {
return;
}

Expand All @@ -32,6 +32,6 @@ protected function canRun()

protected function shouldRun()
{
return ! TaxClass::whereDefault(true)->count();
return !TaxClass::whereDefault(true)->count();
}
}
2 changes: 1 addition & 1 deletion database/state/EnsureUserOrdersHaveACustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EnsureUserOrdersHaveACustomer
{
public function run()
{
if (! $this->canRun()) {
if (!$this->canRun()) {
return;
}

Expand Down
5 changes: 3 additions & 2 deletions src/Actions/Carts/CalculateLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public function __construct(
/**
* Execute the action.
*
* @param \GetCandy\Models\CartLine $cartLine
* @param \Illuminate\Database\Eloquent\Collection $customerGroups
* @param \GetCandy\Models\CartLine $cartLine
* @param \Illuminate\Database\Eloquent\Collection $customerGroups
*
* @return \GetCandy\Models\CartLine
*/
public function execute(
Expand Down
3 changes: 2 additions & 1 deletion src/Actions/Carts/CreateOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public function __construct(OrderReferenceGeneratorInterface $generator)
/**
* Execute the action.
*
* @param \GetCandy\Models\Cart $cart
* @param \GetCandy\Models\Cart $cart
*
* @return void
*/
public function execute(
Expand Down
5 changes: 3 additions & 2 deletions src/Actions/Carts/MergeCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ class MergeCart
/**
* Execute the action.
*
* @param \GetCandy\Models\Cart $target
* @param \GetCandy\Models\Cart $source
* @param \GetCandy\Models\Cart $target
* @param \GetCandy\Models\Cart $source
*
* @return \GetCandy\Models\Cart
*/
public function execute(Cart $target, Cart $source)
Expand Down
9 changes: 5 additions & 4 deletions src/Actions/Carts/ValidateCartForOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class ValidateCartForOrder
/**
* Execute the action.
*
* @param \GetCandy\Models\Cart $cart
* @param \GetCandy\Models\Cart $cart
*
* @return void
*/
public function execute(
Expand All @@ -31,7 +32,7 @@ public function execute(
}

// Do we have a billing address?
if (! $cart->billingAddress) {
if (!$cart->billingAddress) {
throw new BillingAddressMissingException(
__('getcandy::exceptions.carts.billing_missing')
);
Expand All @@ -48,7 +49,7 @@ public function execute(

// Is this cart shippable and if so, does it have a shipping address.
if ($cart->getManager()->isShippable()) {
if (! $cart->shippingAddress) {
if (!$cart->shippingAddress) {
throw new ShippingAddressMissingException(
__('getcandy::exceptions.carts.shipping_missing')
);
Expand All @@ -64,7 +65,7 @@ public function execute(
}

// Do we have a shipping option applied?
if (! $cart->getManager()->getShippingOption()) {
if (!$cart->getManager()->getShippingOption()) {
throw new ShippingOptionMissingException();
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Actions/Collections/SortProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class SortProducts
/**
* Execute the action.
*
* @param \GetCandy\Models\Collection $collection
* @param \GetCandy\Models\Collection $collection
*
* @return void
*/
public function execute(Collection $collection)
Expand Down
7 changes: 4 additions & 3 deletions src/Actions/Collections/SortProductsByPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ class SortProductsByPrice
/**
* Execute the action.
*
* @param \Illuminate\Support\Collection $products
* @param \GetCandy\Models\Currency $currency
* @param string $direction
* @param \Illuminate\Support\Collection $products
* @param \GetCandy\Models\Currency $currency
* @param string $direction
*
* @return void
*/
public function execute(Collection $products, Currency $currency, $direction = 'asc')
Expand Down
5 changes: 3 additions & 2 deletions src/Actions/Collections/SortProductsBySku.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class SortProductsBySku
/**
* Execute the action.
*
* @param \Illuminate\Support\Collection $products
* @param string $direction
* @param \Illuminate\Support\Collection $products
* @param string $direction
*
* @return \Illuminate\Support\Collection
*/
public function execute(Collection $products, $direction = 'asc')
Expand Down
15 changes: 9 additions & 6 deletions src/Actions/Taxes/GetTaxZonePostcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class GetTaxZonePostcode
/**
* Execute the action.
*
* @param string $postcode
* @param string $postcode
*
* @return null|\GetCandy\Models\TaxZonePostcode
*/
public function execute($postcode)
Expand All @@ -20,7 +21,7 @@ public function execute($postcode)
return $postcodeZone;
}

if (! $postcodeZone) {
if (!$postcodeZone) {
return null;
}

Expand All @@ -32,7 +33,7 @@ public function execute($postcode)
})->sort(fn ($current, $next) => $current['matches'] < $next['matches'])->first();

// Give up, use default...
if (! $match) {
if (!$match) {
return null;
}

Expand All @@ -42,7 +43,8 @@ public function execute($postcode)
/**
* Return the zone or zones which match this postcode.
*
* @param string $postcode
* @param string $postcode
*
* @return \GetCandy\Models\TaxZonePostcode|\Illuminate\Support\Collection
*/
protected function getZoneMatches($postcode)
Expand All @@ -59,8 +61,9 @@ protected function getZoneMatches($postcode)
/**
* Match wildcard postcodes and return number of matches.
*
* @param string $wildcard
* @param string $haystack
* @param string $wildcard
* @param string $haystack
*
* @return int
*/
private function matchWildcard($wildcard, $haystack)
Expand Down
5 changes: 3 additions & 2 deletions src/Addons/Manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ public function build()
/**
* Format a given composer package into our addon format.
*
* @param array $package
* @param array $package
*
* @return void|array
*/
protected function formatPackage($package)
{
if (! $provider = $package['extra']['laravel']['providers'][0] ?? null) {
if (!$provider = $package['extra']['laravel']['providers'][0] ?? null) {
return;
}

Expand Down
6 changes: 4 additions & 2 deletions src/Base/AttributeManifestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ interface AttributeManifestInterface
/**
* Add an attribute type.
*
* @param string $classname
* @param string $classname
*
* @return void
*/
public function addType($classname);
Expand All @@ -24,7 +25,8 @@ public function getTypes(): Collection;
/**
* Return an attribute type by it's key.
*
* @param string $handle
* @param string $handle
*
* @return string|null
*/
public function getType($handle);
Expand Down
12 changes: 7 additions & 5 deletions src/Base/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class BaseModel extends Model
/**
* Create a new instance of the Model.
*
* @param array $attributes
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
Expand All @@ -26,8 +26,9 @@ public function __construct(array $attributes = [])
/**
* Handle dynamic method calls into the model.
*
* @param string $method
* @param array $parameters
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public function __call($method, $parameters)
Expand All @@ -42,8 +43,9 @@ public function __call($method, $parameters)
/**
* Handle dynamic static method calls into the model.
*
* @param string $method
* @param array $parameters
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public static function __callStatic($method, $parameters)
Expand Down
16 changes: 10 additions & 6 deletions src/Base/CartSessionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@ public function manager();
/**
* Associate a cart to a user.
*
* @param \GetCandy\Models\Cart $cart
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $policy
* @param \GetCandy\Models\Cart $cart
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $policy
*
* @return void
*/
public function associate(Cart $cart, Authenticatable $user, $policy);

/**
* Use the given cart and set to the session.
*
* @param \GetCandy\Models\Cart $cart
* @param \GetCandy\Models\Cart $cart
*
* @return void
*/
public function use(Cart $cart);
Expand All @@ -58,15 +60,17 @@ public function getSessionKey();
/**
* Set the cart session channel.
*
* @param \GetCandy\Models\Channel $channel
* @param \GetCandy\Models\Channel $channel
*
* @return self
*/
public function setChannel(Channel $channel);

/**
* Set the cart session currency.
*
* @param \GetCandy\Models\Currency $currency
* @param \GetCandy\Models\Currency $currency
*
* @return self
*/
public function setCurrency(Currency $currency);
Expand Down
10 changes: 5 additions & 5 deletions src/Base/Casts/AsAttributeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ class AsAttributeData implements Castable
/**
* Get the caster class to use when casting from / to this cast target.
*
* @param array $arguments
* @param array $arguments
*
* @return object|string
*/
public static function castUsing(array $arguments)
{
return new class() implements CastsAttributes
{
return new class() implements CastsAttributes {
public function get($model, $key, $value, $attributes)
{
if (! isset($attributes[$key])) {
if (!isset($attributes[$key])) {
return null;
}

Expand All @@ -31,7 +31,7 @@ public function get($model, $key, $value, $attributes)
$returnData = new Collection();

foreach ($data as $key => $item) {
if (! in_array(FieldType::class, class_implements($item['field_type']))) {
if (!in_array(FieldType::class, class_implements($item['field_type']))) {
throw new FieldTypeException('This field type is not supported.');
}
$returnData->put($key, new $item['field_type']($item['value']));
Expand Down
18 changes: 10 additions & 8 deletions src/Base/Casts/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ class Price implements CastsAttributes
/**
* Cast the given value.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
*
* @return \GetCandy\DataTypes\Price
*/
public function get($model, $key, $value, $attributes)
Expand Down Expand Up @@ -46,10 +47,11 @@ public function get($model, $key, $value, $attributes)
/**
* Prepare the given value for storage.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param \GetCandy\DataTypes\Price $value
* @param array $attributes
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param \GetCandy\DataTypes\Price $value
* @param array $attributes
*
* @return array
*/
public function set($model, $key, $value, $attributes)
Expand Down
Loading

0 comments on commit c5edd95

Please sign in to comment.