Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Jan 27, 2022
1 parent 5cf71ad commit fea7757
Show file tree
Hide file tree
Showing 26 changed files with 92 additions and 40 deletions.
4 changes: 3 additions & 1 deletion src/CastsEnums.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the CastsEnums trait.
*
Expand Down Expand Up @@ -116,7 +118,7 @@ private function getEnumClass($key)
{
$result = $this->enums[$key];
if (strpos($result, '@')) {
$class = Str::before($result, '@');
$class = Str::before($result, '@');
$method = Str::after($result, '@');

// If no namespace was set, prepend the Model's namespace to the
Expand Down
2 changes: 2 additions & 0 deletions src/Commands/EnumMakeCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Konekt\Enum\Eloquent\Commands;

use Illuminate\Console\GeneratorCommand;
Expand Down
2 changes: 2 additions & 0 deletions src/EnumServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Konekt\Enum\Eloquent;

use Illuminate\Support\ServiceProvider;
Expand Down
2 changes: 2 additions & 0 deletions src/EnumsAreCompatibleWithLaravelForms.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the EnumsAreCompatibleWithLaravelForms trait.
*
Expand Down
4 changes: 3 additions & 1 deletion tests/AAASmokeTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the AAASmokeTest.php class.
*
Expand All @@ -13,7 +15,7 @@

class AAASmokeTest extends TestCase
{
const MIN_PHP_VERSION = '8.0.0';
public const MIN_PHP_VERSION = '8.0.0';

/**
* @test
Expand Down
8 changes: 5 additions & 3 deletions tests/DynamicClassResolverTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the DynamicClassResolverTest class.
*
Expand Down Expand Up @@ -26,7 +28,7 @@ class DynamicClassResolverTest extends TestCase
public function it_resolves_fqcn_enum_class_name_from_the_at_notation()
{
$address = Address::create([
'type' => AddressType::SHIPPING,
'type' => AddressType::SHIPPING,
'address' => 'Richard Avenue 33'
]);

Expand All @@ -39,7 +41,7 @@ public function it_resolves_fqcn_enum_class_name_from_the_at_notation()
public function it_resolves_local_enum_class_name_from_the_at_notation()
{
$address = Address::create([
'type' => AddressType::SHIPPING,
'type' => AddressType::SHIPPING,
'address' => 'Richard Avenue 33'
]);

Expand All @@ -62,7 +64,7 @@ public function at_notation_does_not_collide_if_class_name_is_in_nampespace()
public function it_keeps_original_namespace_with_at_notation_when_using_short_classnames_in_extended_classes()
{
$address = ExtendedAddress::create([
'type' => AddressType::BILLING,
'type' => AddressType::BILLING,
'address' => 'Alexander Platz 1.'
]);

Expand Down
14 changes: 8 additions & 6 deletions tests/EnumAccessorTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the EnumAccessorTest class.
*
Expand All @@ -14,10 +16,10 @@
use Konekt\Enum\Eloquent\Tests\Models\Client;
use Konekt\Enum\Eloquent\Tests\Models\Order;
use Konekt\Enum\Eloquent\Tests\Models\OrderStatus;
use Konekt\Enum\Eloquent\Tests\Models\OrderV2;
use Konekt\Enum\Eloquent\Tests\Models\OrderStatusV2;
use Konekt\Enum\Eloquent\Tests\Models\OrderVX;
use Konekt\Enum\Eloquent\Tests\Models\OrderStatusVX;
use Konekt\Enum\Eloquent\Tests\Models\OrderV2;
use Konekt\Enum\Eloquent\Tests\Models\OrderVX;

class EnumAccessorTest extends TestCase
{
Expand Down Expand Up @@ -111,8 +113,8 @@ public function it_can_still_read_basic_properties_as_well()
public function it_can_still_read_casted_fields()
{
$order = Order::create([
'number' => 'KH8FRWAD',
'status' => OrderStatus::PROCESSING,
'number' => 'KH8FRWAD',
'status' => OrderStatus::PROCESSING,
'is_active' => 1
]);

Expand All @@ -129,8 +131,8 @@ public function it_doesnt_break_related_properties()
$client = Client::create(['name' => 'Britney Spears']);

$order = Order::create([
'number' => 'LDYG4G4',
'status' => OrderStatus::PROCESSING,
'number' => 'LDYG4G4',
'status' => OrderStatus::PROCESSING,
'client_id' => $client->id
]);

Expand Down
4 changes: 3 additions & 1 deletion tests/EnumMutatorTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the EnumMutatorTest class.
*
Expand Down Expand Up @@ -73,7 +75,7 @@ public function it_accepts_enum_object_on_mass_assignment()
public function it_doesnt_accept_scalars_that_arent_valid_enum_values()
{
$this->expectException(\UnexpectedValueException::class);
$order = new Order();
$order = new Order();
$order->status = 'wtf';
}
}
6 changes: 4 additions & 2 deletions tests/EnumToArrayTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the EnumAccessorTest class.
*
Expand All @@ -12,9 +14,9 @@
namespace Konekt\Enum\Eloquent\Tests;

use Konekt\Enum\Eloquent\Tests\Models\Order;
use Konekt\Enum\Eloquent\Tests\Models\OrderStatus;
use Konekt\Enum\Eloquent\Tests\Models\OrderStatusV2;
use Konekt\Enum\Eloquent\Tests\Models\OrderV2;
use Konekt\Enum\Eloquent\Tests\Models\OrderStatus;

class EnumToArrayTest extends TestCase
{
Expand Down Expand Up @@ -63,7 +65,7 @@ public function to_array_still_works()
]);

$attributesArray = $order->attributesToArray();
$array = $order->toArray();
$array = $order->toArray();

$this->assertEquals($array, $attributesArray);
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Models/Address.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the Address class.
*
Expand All @@ -21,7 +23,7 @@ class Address extends Model
protected $guarded = ['id'];

protected $enums = [
'type' => 'Konekt\\Enum\\Eloquent\\Tests\\Resolvers\\AddressTypeResolver@enumClass',
'type' => 'Konekt\\Enum\\Eloquent\\Tests\\Resolvers\\AddressTypeResolver@enumClass',
'status' => 'AddressStatusResolver@enumClass'
];
}
8 changes: 5 additions & 3 deletions tests/Models/AddressStatus.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the AddressStatus class.
*
Expand All @@ -15,7 +17,7 @@

class AddressStatus extends Enum
{
const UNKNOWN = null;
const VALID = 'valid';
const INVALID = 'invalid';
public const UNKNOWN = null;
public const VALID = 'valid';
public const INVALID = 'invalid';
}
2 changes: 2 additions & 0 deletions tests/Models/AddressStatusResolver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the AddressStatusResolver class.
*
Expand Down
6 changes: 4 additions & 2 deletions tests/Models/AddressType.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the AddressType class.
*
Expand All @@ -15,6 +17,6 @@

class AddressType extends Enum
{
const BILLING = 'billing';
const SHIPPING = 'shipping';
public const BILLING = 'billing';
public const SHIPPING = 'shipping';
}
2 changes: 2 additions & 0 deletions tests/Models/Client.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the Client model class.
*
Expand Down
2 changes: 2 additions & 0 deletions tests/Models/Eloquent.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the Squirrel class.
*
Expand Down
8 changes: 5 additions & 3 deletions tests/Models/EloquentType.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the EloquentType enum class.
*
Expand All @@ -15,7 +17,7 @@

class EloquentType extends Enum
{
const NADA = null;
const WHATEVER = 'whatever';
const NEVERMIND = 'nevermind';
public const NADA = null;
public const WHATEVER = 'whatever';
public const NEVERMIND = 'nevermind';
}
2 changes: 2 additions & 0 deletions tests/Models/EloquentTypeProxy.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the EloquentTypeProxy class.
*
Expand Down
2 changes: 2 additions & 0 deletions tests/Models/Extended/Address.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the Address class.
*
Expand Down
2 changes: 2 additions & 0 deletions tests/Models/Order.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the Order model class.
*
Expand Down
12 changes: 7 additions & 5 deletions tests/Models/OrderStatus.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the OrderStatus class.
*
Expand All @@ -15,10 +17,10 @@

class OrderStatus extends Enum
{
const __DEFAULT = self::SUBMITTED;
public const __DEFAULT = self::SUBMITTED;

const SUBMITTED = 'submitted';
const PROCESSING = 'processing';
const SHIPPING = 'shipping';
const COMPLETED = 'completed';
public const SUBMITTED = 'submitted';
public const PROCESSING = 'processing';
public const SHIPPING = 'shipping';
public const COMPLETED = 'completed';
}
12 changes: 7 additions & 5 deletions tests/Models/OrderStatusV2.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the OrderStatus class with Enum version 2 default.
*
Expand All @@ -15,10 +17,10 @@

class OrderStatusV2 extends Enum
{
const __default = self::SUBMITTED;
public const __default = self::SUBMITTED;

const SUBMITTED = 'submitted';
const PROCESSING = 'processing';
const SHIPPING = 'shipping';
const COMPLETED = 'completed';
public const SUBMITTED = 'submitted';
public const PROCESSING = 'processing';
public const SHIPPING = 'shipping';
public const COMPLETED = 'completed';
}
14 changes: 8 additions & 6 deletions tests/Models/OrderStatusVX.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the OrderStatus class with Enum version 2 and 3 default.
*
Expand All @@ -15,11 +17,11 @@

class OrderStatusVX extends Enum
{
const __DEFAULT = self::SUBMITTED;
const __default = self::SUBMITTED; // v2 default for backwards compatibility
public const __DEFAULT = self::SUBMITTED;
public const __default = self::SUBMITTED; // v2 default for backwards compatibility

const SUBMITTED = 'submitted';
const PROCESSING = 'processing';
const SHIPPING = 'shipping';
const COMPLETED = 'completed';
public const SUBMITTED = 'submitted';
public const PROCESSING = 'processing';
public const SHIPPING = 'shipping';
public const COMPLETED = 'completed';
}
2 changes: 2 additions & 0 deletions tests/Models/OrderV2.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the Order model class for Enum version 2 default.
*
Expand Down
2 changes: 2 additions & 0 deletions tests/Models/OrderVX.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the Order model class for Enum version 2 and 3 default.
*
Expand Down
2 changes: 2 additions & 0 deletions tests/Resolvers/AddressTypeResolver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the AddressTypeResolver class.
*
Expand Down
4 changes: 3 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* Contains the TestCase class.
*
Expand Down Expand Up @@ -31,7 +33,7 @@ protected function setUpDatabase()
{
$this->capsule = new Capsule();
$this->capsule->addConnection([
'driver' => 'sqlite',
'driver' => 'sqlite',
'database' => ':memory:',
]);

Expand Down

0 comments on commit fea7757

Please sign in to comment.