Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Sep 8, 2019
1 parent beebbbe commit 3a8f1d3
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 36 deletions.
8 changes: 4 additions & 4 deletions src/Commands/EnumMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

/**
Expand All @@ -54,7 +54,7 @@ protected function getStub()
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace.'\Enums';
return $rootNamespace . '\Enums';
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -15,7 +14,7 @@
*/
function str_before($subject, $search)
{
return $search === '' ? $subject : explode($search, $subject)[0];
return '' === $search ? $subject : explode($search, $subject)[0];
}
}

Expand All @@ -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];
}
}

Expand All @@ -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));
}

Expand Down
1 change: 0 additions & 1 deletion tests/AAASmokeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests;

class AAASmokeTest extends TestCase
Expand Down
1 change: 0 additions & 1 deletion tests/DynamicClassResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests;

use Konekt\Enum\Eloquent\Tests\Models\Address;
Expand Down
24 changes: 12 additions & 12 deletions tests/EnumAccessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests;

use Konekt\Enum\Eloquent\Tests\Models\Client;
Expand All @@ -22,7 +21,6 @@

class EnumAccessorTest extends TestCase
{

/**
* @test
*/
Expand All @@ -45,17 +43,18 @@ 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'
]);

$this->assertInstanceOf(OrderStatus::class, $order->status);
$this->assertEquals(OrderStatus::__DEFAULT, $order->status->value());
}

/**
* @test
*/
Expand All @@ -64,17 +63,18 @@ 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'
]);

$this->assertInstanceOf(OrderStatusV2::class, $order->status);
$this->assertEquals(OrderStatusV2::__default, $order->status->value());
}

/**
* @test
*/
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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];
}
}
1 change: 0 additions & 1 deletion tests/EnumMutatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests;

use Konekt\Enum\Eloquent\Tests\Models\Order;
Expand Down
1 change: 0 additions & 1 deletion tests/Models/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests\Models;

use Illuminate\Database\Eloquent\Model;
Expand Down
1 change: 0 additions & 1 deletion tests/Models/AddressStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests\Models;

use Konekt\Enum\Enum;
Expand Down
1 change: 0 additions & 1 deletion tests/Models/AddressStatusResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests\Models;

class AddressStatusResolver
Expand Down
1 change: 0 additions & 1 deletion tests/Models/AddressType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests\Models;

use Konekt\Enum\Enum;
Expand Down
1 change: 0 additions & 1 deletion tests/Models/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests\Models;

use Illuminate\Database\Eloquent\Model;
Expand Down
1 change: 0 additions & 1 deletion tests/Models/Eloquent.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests\Models;

use Illuminate\Database\Eloquent\Model;
Expand Down
1 change: 0 additions & 1 deletion tests/Models/EloquentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests\Models;

use Konekt\Enum\Enum;
Expand Down
1 change: 0 additions & 1 deletion tests/Models/EloquentTypeProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests\Models;

class EloquentTypeProxy
Expand Down
1 change: 0 additions & 1 deletion tests/Models/Extended/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests\Models\Extended;

class Address extends \Konekt\Enum\Eloquent\Tests\Models\Address
Expand Down
1 change: 0 additions & 1 deletion tests/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests\Models;

use Illuminate\Database\Eloquent\Model;
Expand Down
1 change: 0 additions & 1 deletion tests/Models/OrderStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests\Models;

use Konekt\Enum\Enum;
Expand Down
1 change: 0 additions & 1 deletion tests/Resolvers/AddressTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests\Resolvers;

use Konekt\Enum\Eloquent\Tests\Models\AddressType;
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
*/


namespace Konekt\Enum\Eloquent\Tests;

use Illuminate\Database\Capsule\Manager as Capsule;
Expand Down

0 comments on commit 3a8f1d3

Please sign in to comment.