Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
WatheqAlshowaiter authored and github-actions[bot] committed Jul 18, 2024
1 parent 8831ec3 commit bfcabc7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
32 changes: 17 additions & 15 deletions src/RequiredFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public static function getRequiredFields(
return collect(Schema::getColumns((new self())->getTable()))
->reject(function ($column) use ($primaryIndex, $withNullables, $withDefaults, $withPrimaryKey) {
return
$column['nullable'] && !$withNullables
|| $column['default'] != null && !$withDefaults
|| in_array($column['name'], $primaryIndex) && !$withPrimaryKey;
$column['nullable'] && ! $withNullables
|| $column['default'] != null && ! $withDefaults
|| in_array($column['name'], $primaryIndex) && ! $withPrimaryKey;
})
->pluck('name')
->toArray();
Expand Down Expand Up @@ -109,9 +109,9 @@ private static function getRequiredFieldsForSqlite(

return collect($queryResult)
->reject(function ($column) use ($withNullables, $withDefaults, $withPrimaryKey) {
return $column['pk'] && !$withPrimaryKey
|| $column['dflt_value'] != null && !$withDefaults
|| !$column['notnull'] && !$withNullables;
return $column['pk'] && ! $withPrimaryKey
|| $column['dflt_value'] != null && ! $withDefaults
|| ! $column['notnull'] && ! $withNullables;
})
->pluck('name')
->toArray();
Expand Down Expand Up @@ -152,9 +152,9 @@ private static function getRequiredFieldsForMysqlAndMariaDb(

return collect($queryResult)
->reject(function ($column) use ($withNullables, $withDefaults, $withPrimaryKey) {
return $column['primary'] && !$withPrimaryKey
|| $column['default'] != null && !$withDefaults
|| $column['nullable'] && !$withNullables;
return $column['primary'] && ! $withPrimaryKey
|| $column['default'] != null && ! $withDefaults
|| $column['nullable'] && ! $withNullables;
})
->pluck('name')
->toArray();
Expand Down Expand Up @@ -237,9 +237,9 @@ private static function getRequiredFieldsForPostgres(
return collect($queryResult)
->reject(function ($column) use ($primaryIndex, $withPrimaryKey, $withDefaults, $withNullables) {
return
$column['default'] && !$withDefaults
|| $column['nullable'] == 'YES' && !$withNullables
|| in_array($column['name'], $primaryIndex) && !$withPrimaryKey;
$column['default'] && ! $withDefaults
|| $column['nullable'] == 'YES' && ! $withNullables
|| in_array($column['name'], $primaryIndex) && ! $withPrimaryKey;
})
->pluck('name')
->toArray();
Expand Down Expand Up @@ -283,9 +283,9 @@ private static function getRequiredFieldsForSqlServer(

return collect($queryResult)
->reject(function ($column) use ($withDefaults, $withNullables, $withPrimaryKey) {
return $column['primary'] && !$withPrimaryKey
|| $column['default'] != null && !$withDefaults
|| $column['nullable'] && !$withNullables;
return $column['primary'] && ! $withPrimaryKey
|| $column['default'] != null && ! $withDefaults
|| $column['nullable'] && ! $withNullables;
})
->pluck('name')
->toArray();
Expand Down Expand Up @@ -320,10 +320,12 @@ public static function getRequiredFieldsWithDefaultsAndPrimaryKey()
{
return self::getRequiredFields($withNullables = false, $withDefaults = true, $withPrimaryKey = true);
}

public static function getRequiredFieldsWithNullablesAndDefaults()
{
return self::getRequiredFields($withNullables = true, $withDefaults = true, $withPrimaryKey = false);
}

public static function getRequiredFieldsWithNullablesAndPrimaryKey()
{
return self::getRequiredFields($withNullables = true, $withDefaults = false, $withPrimaryKey = true);
Expand Down
3 changes: 2 additions & 1 deletion tests/RequiredFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public function test_get_required_with_nullables_and_defaults()
));
$this->assertEquals($expected, Father::getRequiredFieldsWithNullablesAndDefaults());
}

public function test_get_required_with_nullables_and_primary_key()
{
$expected = [
Expand Down Expand Up @@ -176,7 +177,7 @@ public function test_get_required_with_defaults_and_nullables_and_primary_key()
'username',
'created_at',
'updated_at',
'deleted_at'
'deleted_at',
];

$this->assertEquals($expected, Father::getRequiredFields(
Expand Down

0 comments on commit bfcabc7

Please sign in to comment.