Jeroen De Dauw has submitted this change and it was merged.

Change subject: Simplify FieldDefinition constructor
......................................................................


Simplify FieldDefinition constructor

Change-Id: I069ec4accfcf84974c1b4c82f0daa1aaa31fdad6
---
M src/Schema/Definitions/FieldDefinition.php
1 file changed, 29 insertions(+), 16 deletions(-)

Approvals:
  Jeroen De Dauw: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/Schema/Definitions/FieldDefinition.php 
b/src/Schema/Definitions/FieldDefinition.php
index 859a1b3..0864dc7 100644
--- a/src/Schema/Definitions/FieldDefinition.php
+++ b/src/Schema/Definitions/FieldDefinition.php
@@ -82,24 +82,13 @@
         * @param string|null $attributes
         * @param boolean $autoIncrement
         *
-        * @throws \InvalidArgumentException
+        * @throws InvalidArgumentException
         */
        public function __construct( $name, $type, $null = self::NULL, $default 
= self::NO_DEFAULT, $attributes = null, $autoIncrement = false ) {
-               if ( !is_string( $name ) ) {
-                       throw new InvalidArgumentException( 'The field $name 
needs to be a string' );
-               }
-
-               if ( !is_string( $type ) ) {
-                       throw new InvalidArgumentException( 'The field $type 
needs to be a string' );
-               }
-
-               if ( !is_bool( $null ) ) {
-                       throw new InvalidArgumentException( 'The $null 
parameter needs to be a boolean' );
-               }
-
-               if ( !is_bool( $autoIncrement ) ) {
-                       throw new InvalidArgumentException( 'The $autoIncrement 
parameter needs to be a boolean' );
-               }
+               $this->assertIsValidName( $name );
+               $this->assertIsValidType( $type );
+               $this->assertIsValudNull( $null );
+               $this->assertIsValidAutoIncrement( $autoIncrement );
 
                $this->name = $name;
                $this->type = $type;
@@ -179,4 +168,28 @@
                return $this->autoIncrement;
        }
 
+       private function assertIsValidName( $name ) {
+               if ( !is_string( $name ) ) {
+                       throw new InvalidArgumentException( 'The field $name 
needs to be a string' );
+               }
+       }
+
+       private function assertIsValidType( $type ) {
+               if ( !is_string( $type ) ) {
+                       throw new InvalidArgumentException( 'The field $type 
needs to be a string' );
+               }
+       }
+
+       private function assertIsValudNull( $null ) {
+               if ( !is_bool( $null ) ) {
+                       throw new InvalidArgumentException( 'The $null 
parameter needs to be a boolean' );
+               }
+       }
+
+       private function assertIsValidAutoIncrement( $autoIncrement ) {
+               if ( !is_bool( $autoIncrement ) ) {
+                       throw new InvalidArgumentException( 'The $autoIncrement 
parameter needs to be a boolean' );
+               }
+       }
+
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/89161
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I069ec4accfcf84974c1b4c82f0daa1aaa31fdad6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseDatabase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to