From 3c373c256cf351b5a31df72c02219497072c68bb Mon Sep 17 00:00:00 2001 From: Naoray Date: Tue, 9 Feb 2021 09:16:10 +0000 Subject: [PATCH] Apply fixes from StyleCI [ci skip] [skip ci] --- src/Column.php | 12 +++---- src/RelationMethod.php | 10 +++--- tests/ColumnsDetectorTest.php | 48 ++++++++++++++-------------- tests/RelationMethodDetectorTest.php | 48 ++++++++++++++-------------- 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/Column.php b/src/Column.php index 3b3ebeb..e685a88 100644 --- a/src/Column.php +++ b/src/Column.php @@ -43,12 +43,12 @@ public function __construct(string $column, string $table) public function toArray(): array { return [ - 'name' => $this->column, - 'type' => $this->typeClass(), - 'unsigned' => $this->data->getUnsigned(), - 'unique' => $this->isUnique(), - 'isForeignKey' => $this->isForeignKey(), - 'nullable' => ! $this->data->getNotnull(), + 'name' => $this->column, + 'type' => $this->typeClass(), + 'unsigned' => $this->data->getUnsigned(), + 'unique' => $this->isUnique(), + 'isForeignKey' => $this->isForeignKey(), + 'nullable' => !$this->data->getNotnull(), 'autoincrement' => $this->data->getAutoincrement(), ]; } diff --git a/src/RelationMethod.php b/src/RelationMethod.php index bc23c9d..786181b 100644 --- a/src/RelationMethod.php +++ b/src/RelationMethod.php @@ -47,10 +47,10 @@ public function toArray(): array { return [ 'relatedClass' => $this->getRelatedClass(), - 'type' => $this->returnType(), - 'foreignKey' => $this->foreignKey(), - 'ownerKey' => $this->ownerKey(), - 'methodName' => $this->getName(), + 'type' => $this->returnType(), + 'foreignKey' => $this->foreignKey(), + 'ownerKey' => $this->ownerKey(), + 'methodName' => $this->getName(), ]; } @@ -71,7 +71,7 @@ public function getRelatedClass(): string * If classname does not use ::class notation * we consider it as a full class string reference. */ - if (! $className->is('*::class')) { + if (!$className->is('*::class')) { return $className; } diff --git a/tests/ColumnsDetectorTest.php b/tests/ColumnsDetectorTest.php index 664e4ff..3ec6b2f 100644 --- a/tests/ColumnsDetectorTest.php +++ b/tests/ColumnsDetectorTest.php @@ -33,39 +33,39 @@ public function up() $this->assertCount(4, $fields); $this->assertEquals([ - 'name' => 'id', - 'type' => IntegerType::class, - 'unsigned' => false, - 'unique' => true, - 'isForeignKey' => false, - 'nullable' => false, + 'name' => 'id', + 'type' => IntegerType::class, + 'unsigned' => false, + 'unique' => true, + 'isForeignKey' => false, + 'nullable' => false, 'autoincrement' => true, ], $fields->get('id')->toArray()); $this->assertEquals([ - 'name' => 'name', - 'type' => StringType::class, - 'unsigned' => false, - 'unique' => false, - 'isForeignKey' => false, - 'nullable' => false, + 'name' => 'name', + 'type' => StringType::class, + 'unsigned' => false, + 'unique' => false, + 'isForeignKey' => false, + 'nullable' => false, 'autoincrement' => false, ], $fields->get('name')->toArray()); $this->assertEquals([ - 'name' => 'email', - 'type' => StringType::class, - 'unsigned' => false, - 'unique' => true, - 'isForeignKey' => false, - 'nullable' => false, + 'name' => 'email', + 'type' => StringType::class, + 'unsigned' => false, + 'unique' => true, + 'isForeignKey' => false, + 'nullable' => false, 'autoincrement' => false, ], $fields->get('email')->toArray()); $this->assertEquals([ - 'name' => 'bio', - 'type' => TextType::class, - 'unsigned' => false, - 'unique' => false, - 'isForeignKey' => false, - 'nullable' => true, + 'name' => 'bio', + 'type' => TextType::class, + 'unsigned' => false, + 'unique' => false, + 'isForeignKey' => false, + 'nullable' => true, 'autoincrement' => false, ], $fields->get('bio')->toArray()); } diff --git a/tests/RelationMethodDetectorTest.php b/tests/RelationMethodDetectorTest.php index 54e9f05..df17fa8 100644 --- a/tests/RelationMethodDetectorTest.php +++ b/tests/RelationMethodDetectorTest.php @@ -17,17 +17,17 @@ public function it_can_get_relation_methods_of_a_model_by_return_type() $this->assertCount(2, $relationMethods); $this->assertEquals([ 'relatedClass' => UserWithReturnTypes::class, - 'type' => BelongsTo::class, - 'foreignKey' => 'parent_id', - 'ownerKey' => 'id', - 'methodName' => 'parent', + 'type' => BelongsTo::class, + 'foreignKey' => 'parent_id', + 'ownerKey' => 'id', + 'methodName' => 'parent', ], $relationMethods->first()->toArray()); $this->assertEquals([ 'relatedClass' => Post::class, - 'type' => HasMany::class, - 'foreignKey' => 'user_id', - 'ownerKey' => 'id', - 'methodName' => 'posts', + 'type' => HasMany::class, + 'foreignKey' => 'user_id', + 'ownerKey' => 'id', + 'methodName' => 'posts', ], $relationMethods->get(1)->toArray()); } @@ -41,17 +41,17 @@ public function it_can_get_relation_methods_of_a_model_by_doc_comment() $this->assertCount(2, $relationMethods); $this->assertEquals([ 'relatedClass' => UserWithDocComments::class, - 'type' => BelongsTo::class, - 'foreignKey' => 'parent_id', - 'ownerKey' => 'id', - 'methodName' => 'parent', + 'type' => BelongsTo::class, + 'foreignKey' => 'parent_id', + 'ownerKey' => 'id', + 'methodName' => 'parent', ], $relationMethods->first()->toArray()); $this->assertEquals([ 'relatedClass' => Post::class, - 'type' => HasMany::class, - 'foreignKey' => 'user_id', - 'ownerKey' => 'id', - 'methodName' => 'posts', + 'type' => HasMany::class, + 'foreignKey' => 'user_id', + 'ownerKey' => 'id', + 'methodName' => 'posts', ], $relationMethods->get(1)->toArray()); } @@ -65,17 +65,17 @@ public function it_can_get_relation_methods_of_a_model_by_method_content() $this->assertCount(2, $relationMethods); $this->assertEquals([ 'relatedClass' => UserWithoutAnyHints::class, - 'type' => BelongsTo::class, - 'foreignKey' => 'parent_id', - 'ownerKey' => 'id', - 'methodName' => 'parent', + 'type' => BelongsTo::class, + 'foreignKey' => 'parent_id', + 'ownerKey' => 'id', + 'methodName' => 'parent', ], $relationMethods->first()->toArray()); $this->assertEquals([ 'relatedClass' => Post::class, - 'type' => HasMany::class, - 'foreignKey' => 'user_id', - 'ownerKey' => 'id', - 'methodName' => 'posts', + 'type' => HasMany::class, + 'foreignKey' => 'user_id', + 'ownerKey' => 'id', + 'methodName' => 'posts', ], $relationMethods->get(1)->toArray()); } }