diff --git a/src/Commands/EnumMakeCommand.php b/src/Commands/EnumMakeCommand.php index 515fd0a..309f19a 100644 --- a/src/Commands/EnumMakeCommand.php +++ b/src/Commands/EnumMakeCommand.php @@ -36,14 +36,14 @@ class EnumMakeCommand extends GeneratorCommand protected function getStub() { if ($this->option('labels')) { - return __DIR__.'/stubs/enum.labels.stub'; + return __DIR__ . '/stubs/enum.labels.stub'; } if ($this->option('boot')) { - return __DIR__.'/stubs/enum.boot.stub'; + return __DIR__ . '/stubs/enum.boot.stub'; } - return __DIR__.'/stubs/enum.stub'; + return __DIR__ . '/stubs/enum.stub'; } /** @@ -54,7 +54,7 @@ protected function getStub() */ protected function getDefaultNamespace($rootNamespace) { - return $rootNamespace.'\Enums'; + return $rootNamespace . '\Enums'; } /** diff --git a/src/functions.php b/src/functions.php index 6ab94ae..255bcf3 100644 --- a/src/functions.php +++ b/src/functions.php @@ -4,7 +4,6 @@ * - str_before on Laravel < v5.5 * - str_after on Laravel < v5.4 */ - if (!function_exists('str_before')) { /** * Get the portion of a string before a given value. @@ -15,7 +14,7 @@ */ function str_before($subject, $search) { - return $search === '' ? $subject : explode($search, $subject)[0]; + return '' === $search ? $subject : explode($search, $subject)[0]; } } @@ -29,7 +28,7 @@ function str_before($subject, $search) */ function str_after($subject, $search) { - return $search === '' ? $subject : array_reverse(explode($search, $subject, 2))[0]; + return '' === $search ? $subject : array_reverse(explode($search, $subject, 2))[0]; } } @@ -46,7 +45,7 @@ function str_replace_last($search, $replace, $subject) { $position = strrpos($subject, $search); - if ($position !== false) { + if (false !== $position) { return substr_replace($subject, $replace, $position, strlen($search)); } diff --git a/tests/AAASmokeTest.php b/tests/AAASmokeTest.php index cbe02c5..e241598 100644 --- a/tests/AAASmokeTest.php +++ b/tests/AAASmokeTest.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests; class AAASmokeTest extends TestCase diff --git a/tests/DynamicClassResolverTest.php b/tests/DynamicClassResolverTest.php index ba0268b..adfe807 100644 --- a/tests/DynamicClassResolverTest.php +++ b/tests/DynamicClassResolverTest.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests; use Konekt\Enum\Eloquent\Tests\Models\Address; diff --git a/tests/EnumAccessorTest.php b/tests/EnumAccessorTest.php index 33cf54f..c481aab 100644 --- a/tests/EnumAccessorTest.php +++ b/tests/EnumAccessorTest.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests; use Konekt\Enum\Eloquent\Tests\Models\Client; @@ -22,7 +21,6 @@ class EnumAccessorTest extends TestCase { - /** * @test */ @@ -45,9 +43,10 @@ public function it_returns_the_enum_default_when_attribute_is_null() // don't test if mayor version is lower than 3 if ($this->getEnumVersionMajor() < 3) { $this->assertTrue(true); + return; } - + $order = new Order([ 'number' => 'PLGU7S5' ]); @@ -55,7 +54,7 @@ public function it_returns_the_enum_default_when_attribute_is_null() $this->assertInstanceOf(OrderStatus::class, $order->status); $this->assertEquals(OrderStatus::__DEFAULT, $order->status->value()); } - + /** * @test */ @@ -64,9 +63,10 @@ public function it_returns_the_enum_v2_default_when_attribute_is_null() // don't test if mayor version is 3 or higher if ($this->getEnumVersionMajor() >= 3) { $this->assertTrue(true); + return; } - + $order = new OrderV2([ 'number' => 'PLGU7S5' ]); @@ -74,7 +74,7 @@ public function it_returns_the_enum_v2_default_when_attribute_is_null() $this->assertInstanceOf(OrderStatusV2::class, $order->status); $this->assertEquals(OrderStatusV2::__default, $order->status->value()); } - + /** * @test */ @@ -116,7 +116,7 @@ public function it_can_still_read_casted_fields() $this->assertNotNull($order->id); $this->assertInstanceOf(\DateTime::class, $order->created_at); - $this->assertInternalType('boolean', $order->is_active); + $this->assertIsBool($order->is_active); } /** @@ -135,20 +135,20 @@ public function it_doesnt_break_related_properties() $this->assertInstanceOf(Client::class, $order->client); $this->assertEquals($client->id, $order->client->id); } - + private function getEnumVersion() { $raw_version = \PackageVersions\Versions::getVersion('konekt/enum'); - + $parts = explode('@', $raw_version); - + return $parts[0]; } - + private function getEnumVersionMajor() { $parts = explode('.', $this->getEnumVersion()); - + return $parts[0]; } } diff --git a/tests/EnumMutatorTest.php b/tests/EnumMutatorTest.php index c6c16ab..9fa2327 100644 --- a/tests/EnumMutatorTest.php +++ b/tests/EnumMutatorTest.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests; use Konekt\Enum\Eloquent\Tests\Models\Order; diff --git a/tests/Models/Address.php b/tests/Models/Address.php index d550866..dd60170 100644 --- a/tests/Models/Address.php +++ b/tests/Models/Address.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests\Models; use Illuminate\Database\Eloquent\Model; diff --git a/tests/Models/AddressStatus.php b/tests/Models/AddressStatus.php index 2de6654..a13d1da 100644 --- a/tests/Models/AddressStatus.php +++ b/tests/Models/AddressStatus.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests\Models; use Konekt\Enum\Enum; diff --git a/tests/Models/AddressStatusResolver.php b/tests/Models/AddressStatusResolver.php index fdb3226..6d5794d 100644 --- a/tests/Models/AddressStatusResolver.php +++ b/tests/Models/AddressStatusResolver.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests\Models; class AddressStatusResolver diff --git a/tests/Models/AddressType.php b/tests/Models/AddressType.php index 9164fa1..af893ef 100644 --- a/tests/Models/AddressType.php +++ b/tests/Models/AddressType.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests\Models; use Konekt\Enum\Enum; diff --git a/tests/Models/Client.php b/tests/Models/Client.php index 6174334..aabd878 100644 --- a/tests/Models/Client.php +++ b/tests/Models/Client.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests\Models; use Illuminate\Database\Eloquent\Model; diff --git a/tests/Models/Eloquent.php b/tests/Models/Eloquent.php index 5cc1829..b0eaa05 100644 --- a/tests/Models/Eloquent.php +++ b/tests/Models/Eloquent.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests\Models; use Illuminate\Database\Eloquent\Model; diff --git a/tests/Models/EloquentType.php b/tests/Models/EloquentType.php index e2d35b6..bfc2408 100644 --- a/tests/Models/EloquentType.php +++ b/tests/Models/EloquentType.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests\Models; use Konekt\Enum\Enum; diff --git a/tests/Models/EloquentTypeProxy.php b/tests/Models/EloquentTypeProxy.php index 0e42900..7433b1d 100644 --- a/tests/Models/EloquentTypeProxy.php +++ b/tests/Models/EloquentTypeProxy.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests\Models; class EloquentTypeProxy diff --git a/tests/Models/Extended/Address.php b/tests/Models/Extended/Address.php index f242627..6883eab 100644 --- a/tests/Models/Extended/Address.php +++ b/tests/Models/Extended/Address.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests\Models\Extended; class Address extends \Konekt\Enum\Eloquent\Tests\Models\Address diff --git a/tests/Models/Order.php b/tests/Models/Order.php index 422408a..8bfe240 100644 --- a/tests/Models/Order.php +++ b/tests/Models/Order.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests\Models; use Illuminate\Database\Eloquent\Model; diff --git a/tests/Models/OrderStatus.php b/tests/Models/OrderStatus.php index 9d1be0a..a128416 100644 --- a/tests/Models/OrderStatus.php +++ b/tests/Models/OrderStatus.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests\Models; use Konekt\Enum\Enum; diff --git a/tests/Resolvers/AddressTypeResolver.php b/tests/Resolvers/AddressTypeResolver.php index 0d6bc1b..26e31c0 100644 --- a/tests/Resolvers/AddressTypeResolver.php +++ b/tests/Resolvers/AddressTypeResolver.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests\Resolvers; use Konekt\Enum\Eloquent\Tests\Models\AddressType; diff --git a/tests/TestCase.php b/tests/TestCase.php index 698693f..2eaef8d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -9,7 +9,6 @@ * */ - namespace Konekt\Enum\Eloquent\Tests; use Illuminate\Database\Capsule\Manager as Capsule;