| @@ -35,7 +35,7 @@ discard block | ||
| 35 | 35 | * @param Schema $schema | 
| 36 | 36 | * @return bool | 
| 37 | 37 | */ | 
| 38 | - public function create_table( Schema $schema ): bool; | |
| 38 | + public function create_table(Schema $schema): bool; | |
| 39 | 39 | |
| 40 | 40 | /** | 
| 41 | 41 | * Returns the query generated to create a table. | 
| @@ -43,7 +43,7 @@ discard block | ||
| 43 | 43 | * @param \PinkCrab\Table_Builder\Schema $schema | 
| 44 | 44 | * @return string | 
| 45 | 45 | */ | 
| 46 | - public function create_table_query( Schema $schema ): string; | |
| 46 | + public function create_table_query(Schema $schema): string; | |
| 47 | 47 | |
| 48 | 48 | /** | 
| 49 | 49 | * Drops a table based on the schema passed. | 
| @@ -51,7 +51,7 @@ discard block | ||
| 51 | 51 | * @param Schema $schema | 
| 52 | 52 | * @return bool | 
| 53 | 53 | */ | 
| 54 | - public function drop_table( Schema $schema): bool; | |
| 54 | + public function drop_table(Schema $schema): bool; | |
| 55 | 55 | |
| 56 | 56 | /** | 
| 57 | 57 | * Returns the query generated to drop a table. | 
| @@ -59,5 +59,5 @@ discard block | ||
| 59 | 59 | * @param \PinkCrab\Table_Builder\Schema $schema | 
| 60 | 60 | * @return string | 
| 61 | 61 | */ | 
| 62 | - public function drop_table_query( Schema $schema ): string; | |
| 62 | + public function drop_table_query(Schema $schema): string; | |
| 63 | 63 | } | 
| @@ -80,10 +80,10 @@ discard block | ||
| 80 | 80 | * @param string $table_name | 
| 81 | 81 | * @param callable(Schema):void|null $configure | 
| 82 | 82 | */ | 
| 83 | -	public function __construct( string $table_name, ?callable $configure = null ) { | |
| 83 | +	public function __construct(string $table_name, ?callable $configure = null) { | |
| 84 | 84 | $this->table_name = $table_name; | 
| 85 | -		if ( is_callable( $configure ) ) { | |
| 86 | - $configure( $this ); | |
| 85 | +		if (is_callable($configure)) { | |
| 86 | + $configure($this); | |
| 87 | 87 | } | 
| 88 | 88 | } | 
| 89 | 89 | |
| @@ -110,7 +110,7 @@ discard block | ||
| 110 | 110 | * @param string|null $prefix | 
| 111 | 111 | * @return self | 
| 112 | 112 | */ | 
| 113 | -	public function prefix( ?string $prefix = null ): self { | |
| 113 | +	public function prefix(?string $prefix = null): self { | |
| 114 | 114 | $this->prefix = $prefix; | 
| 115 | 115 | return $this; | 
| 116 | 116 | } | 
| @@ -143,10 +143,10 @@ discard block | ||
| 143 | 143 | * @param string $name | 
| 144 | 144 | * @return Column | 
| 145 | 145 | */ | 
| 146 | -	public function column( string $name ): Column { | |
| 147 | - $column = new Column( $name ); | |
| 146 | +	public function column(string $name): Column { | |
| 147 | + $column = new Column($name); | |
| 148 | 148 | |
| 149 | - $this->columns[ $name ] = $column; | |
| 149 | + $this->columns[$name] = $column; | |
| 150 | 150 | return $column; | 
| 151 | 151 | } | 
| 152 | 152 | |
| @@ -168,11 +168,11 @@ discard block | ||
| 168 | 168 | * @param string $name | 
| 169 | 169 | * @return bool | 
| 170 | 170 | */ | 
| 171 | -	public function has_column( string $name ): bool { | |
| 171 | +	public function has_column(string $name): bool { | |
| 172 | 172 | return count( | 
| 173 | 173 | array_filter( | 
| 174 | 174 | $this->get_columns(), | 
| 175 | -				function( Column $column ) use ( $name ): bool { | |
| 175 | +				function(Column $column) use ($name): bool { | |
| 176 | 176 | return $column->get_name() === $name; | 
| 177 | 177 | } | 
| 178 | 178 | ) | 
| @@ -187,12 +187,12 @@ discard block | ||
| 187 | 187 | * @return self | 
| 188 | 188 | * @throws Schema_Exception (301) If column doesn't exist. | 
| 189 | 189 | */ | 
| 190 | -	public function remove_column( string $name ): self { | |
| 191 | -		if ( ! $this->has_column( $name ) ) { | |
| 192 | - throw Schema_Exception::column_not_exist( $this, $name ); | |
| 190 | +	public function remove_column(string $name): self { | |
| 191 | +		if ( ! $this->has_column($name)) { | |
| 192 | + throw Schema_Exception::column_not_exist($this, $name); | |
| 193 | 193 | } | 
| 194 | 194 | |
| 195 | - unset( $this->columns[ $name ] ); | |
| 195 | + unset($this->columns[$name]); | |
| 196 | 196 | |
| 197 | 197 | return $this; | 
| 198 | 198 | } | 
| @@ -205,8 +205,8 @@ discard block | ||
| 205 | 205 | * @param string|null $key_name if not set, will use the column name a tempalte. | 
| 206 | 206 | * @return \PinkCrab\Table_Builder\Foreign_Key | 
| 207 | 207 | */ | 
| 208 | -	public function foreign_key( string $column, ?string $key_name = null ): Foreign_Key { | |
| 209 | - $foreign_key = new Foreign_Key( $column, $key_name ); | |
| 208 | +	public function foreign_key(string $column, ?string $key_name = null): Foreign_Key { | |
| 209 | + $foreign_key = new Foreign_Key($column, $key_name); | |
| 210 | 210 | |
| 211 | 211 | $this->foreign_keys[] = $foreign_key; | 
| 212 | 212 | return $foreign_key; | 
| @@ -218,7 +218,7 @@ discard block | ||
| 218 | 218 | * @return bool | 
| 219 | 219 | */ | 
| 220 | 220 |  	public function has_foreign_keys(): bool { | 
| 221 | - return count( $this->foreign_keys ) !== 0; | |
| 221 | + return count($this->foreign_keys) !== 0; | |
| 222 | 222 | } | 
| 223 | 223 | |
| 224 | 224 | /** | 
| @@ -238,7 +238,7 @@ discard block | ||
| 238 | 238 | * @return bool | 
| 239 | 239 | */ | 
| 240 | 240 |  	public function has_indexes(): bool { | 
| 241 | - return count( $this->indexes ) !== 0; | |
| 241 | + return count($this->indexes) !== 0; | |
| 242 | 242 | } | 
| 243 | 243 | |
| 244 | 244 | /** | 
| @@ -248,8 +248,8 @@ discard block | ||
| 248 | 248 | * @param string $key_name | 
| 249 | 249 | * @return \PinkCrab\Table_Builder\Index | 
| 250 | 250 | */ | 
| 251 | -	public function index( string $column, ?string $key_name = null ): Index { | |
| 252 | - $index = new Index( $column, $key_name ); | |
| 251 | +	public function index(string $column, ?string $key_name = null): Index { | |
| 252 | + $index = new Index($column, $key_name); | |
| 253 | 253 | |
| 254 | 254 | $this->indexes[] = $index; | 
| 255 | 255 | return $index; | 
| @@ -45,7 +45,7 @@ discard block | ||
| 45 | 45 | ?Throwable $previous = null | 
| 46 | 46 |  	) { | 
| 47 | 47 | $this->schema = $schema; | 
| 48 | - parent::__construct( $message, $code, $previous ); | |
| 48 | + parent::__construct($message, $code, $previous); | |
| 49 | 49 | } | 
| 50 | 50 | |
| 51 | 51 | /** | 
| @@ -64,10 +64,10 @@ discard block | ||
| 64 | 64 | * @param string $column | 
| 65 | 65 | * @return Schema_Exception | 
| 66 | 66 | */ | 
| 67 | -	public static function column_not_exist( Schema $schema, string $column ): Schema_Exception { | |
| 67 | +	public static function column_not_exist(Schema $schema, string $column): Schema_Exception { | |
| 68 | 68 | return new Schema_Exception( | 
| 69 | 69 | $schema, | 
| 70 | - \sprintf( 'column with name %s is not currently defined', $column ), | |
| 70 | +			\sprintf('column with name %s is not currently defined', $column), | |
| 71 | 71 | 301 | 
| 72 | 72 | ); | 
| 73 | 73 | } | 
| @@ -61,7 +61,7 @@ discard block | ||
| 61 | 61 |  	) { | 
| 62 | 62 | $this->schema = $schema; | 
| 63 | 63 | $this->validation_errors = $validation_errors; | 
| 64 | - parent::__construct( $message, $code, $previous ); | |
| 64 | + parent::__construct($message, $code, $previous); | |
| 65 | 65 | } | 
| 66 | 66 | |
| 67 | 67 | /** | 
| @@ -72,11 +72,11 @@ discard block | ||
| 72 | 72 | * @return WPDB_Validator_Exception | 
| 73 | 73 | * @code 201 | 
| 74 | 74 | */ | 
| 75 | -	public static function failed_validation( Schema $schema, array $errors ): WPDB_Validator_Exception { | |
| 75 | +	public static function failed_validation(Schema $schema, array $errors): WPDB_Validator_Exception { | |
| 76 | 76 | return new WPDB_Validator_Exception( | 
| 77 | 77 | $schema, | 
| 78 | 78 | $errors, | 
| 79 | - sprintf( '%s failed with %d errors', $schema->get_table_name(), count( $errors ) ), | |
| 79 | +			sprintf('%s failed with %d errors', $schema->get_table_name(), count($errors)), | |
| 80 | 80 | 201 | 
| 81 | 81 | ); | 
| 82 | 82 | } | 
| @@ -45,7 +45,7 @@ discard block | ||
| 45 | 45 | ?Throwable $previous = null | 
| 46 | 46 |  	) { | 
| 47 | 47 | $this->schema = $schema; | 
| 48 | - parent::__construct( $message, $code, $previous ); | |
| 48 | + parent::__construct($message, $code, $previous); | |
| 49 | 49 | } | 
| 50 | 50 | |
| 51 | 51 | /** | 
| @@ -65,8 +65,8 @@ discard block | ||
| 65 | 65 | * @return Engine_Exception | 
| 66 | 66 | * @code 101 | 
| 67 | 67 | */ | 
| 68 | -	public static function create_table( Schema $schema, string $error ): Engine_Exception { | |
| 69 | - return new self( $schema, $error, 101 ); | |
| 68 | +	public static function create_table(Schema $schema, string $error): Engine_Exception { | |
| 69 | + return new self($schema, $error, 101); | |
| 70 | 70 | } | 
| 71 | 71 | |
| 72 | 72 | /** | 
| @@ -77,7 +77,7 @@ discard block | ||
| 77 | 77 | * @return Engine_Exception | 
| 78 | 78 | * @code 102 | 
| 79 | 79 | */ | 
| 80 | -	public static function drop_table( Schema $schema, string $error ): Engine_Exception { | |
| 81 | - return new self( $schema, $error, 102 ); | |
| 80 | +	public static function drop_table(Schema $schema, string $error): Engine_Exception { | |
| 81 | + return new self($schema, $error, 102); | |
| 82 | 82 | } | 
| 83 | 83 | } | 
| @@ -36,10 +36,10 @@ discard block | ||
| 36 | 36 | * @param int|null $length | 
| 37 | 37 | * @return Column | 
| 38 | 38 | */ | 
| 39 | -	public function varchar( ?int $length = null ): Column { | |
| 40 | - $this->type( 'varchar' ); | |
| 41 | -		if ( null !== $length ) { | |
| 42 | - $this->length( $length ); | |
| 39 | +	public function varchar(?int $length = null): Column { | |
| 40 | +		$this->type('varchar'); | |
| 41 | +		if (null !== $length) { | |
| 42 | + $this->length($length); | |
| 43 | 43 | } | 
| 44 | 44 | return $this; | 
| 45 | 45 | } | 
| @@ -51,10 +51,10 @@ discard block | ||
| 51 | 51 | * @param int|null $length | 
| 52 | 52 | * @return Column | 
| 53 | 53 | */ | 
| 54 | -	public function text( ?int $length = null ): Column { | |
| 55 | - $this->type( 'text' ); | |
| 56 | -		if ( null !== $length ) { | |
| 57 | - $this->length( $length ); | |
| 54 | +	public function text(?int $length = null): Column { | |
| 55 | +		$this->type('text'); | |
| 56 | +		if (null !== $length) { | |
| 57 | + $this->length($length); | |
| 58 | 58 | } | 
| 59 | 59 | return $this; | 
| 60 | 60 | } | 
| @@ -66,10 +66,10 @@ discard block | ||
| 66 | 66 | * @param int|null $length | 
| 67 | 67 | * @return Column | 
| 68 | 68 | */ | 
| 69 | -	public function int( ?int $length = null ): Column { | |
| 70 | - $this->type( 'int' ); | |
| 71 | -		if ( null !== $length ) { | |
| 72 | - $this->length( $length ); | |
| 69 | +	public function int(?int $length = null): Column { | |
| 70 | +		$this->type('int'); | |
| 71 | +		if (null !== $length) { | |
| 72 | + $this->length($length); | |
| 73 | 73 | } | 
| 74 | 74 | return $this; | 
| 75 | 75 | } | 
| @@ -82,13 +82,13 @@ discard block | ||
| 82 | 82 | * @param int|null $precision | 
| 83 | 83 | * @return Column | 
| 84 | 84 | */ | 
| 85 | -	public function float( ?int $length = null, ?int $precision = null ): Column { | |
| 86 | - $this->type( 'float' ); | |
| 87 | -		if ( null !== $length ) { | |
| 88 | - $this->length( $length ); | |
| 85 | +	public function float(?int $length = null, ?int $precision = null): Column { | |
| 86 | +		$this->type('float'); | |
| 87 | +		if (null !== $length) { | |
| 88 | + $this->length($length); | |
| 89 | 89 | } | 
| 90 | -		if ( null !== $precision ) { | |
| 91 | - $this->precision( $precision ); | |
| 90 | +		if (null !== $precision) { | |
| 91 | + $this->precision($precision); | |
| 92 | 92 | } | 
| 93 | 93 | return $this; | 
| 94 | 94 | } | 
| @@ -101,13 +101,13 @@ discard block | ||
| 101 | 101 | * @param int|null $precision | 
| 102 | 102 | * @return Column | 
| 103 | 103 | */ | 
| 104 | -	public function double( ?int $length = null, ?int $precision = null ): Column { | |
| 105 | - $this->type( 'double' ); | |
| 106 | -		if ( null !== $length ) { | |
| 107 | - $this->length( $length ); | |
| 104 | +	public function double(?int $length = null, ?int $precision = null): Column { | |
| 105 | +		$this->type('double'); | |
| 106 | +		if (null !== $length) { | |
| 107 | + $this->length($length); | |
| 108 | 108 | } | 
| 109 | -		if ( null !== $precision ) { | |
| 110 | - $this->precision( $precision ); | |
| 109 | +		if (null !== $precision) { | |
| 110 | + $this->precision($precision); | |
| 111 | 111 | } | 
| 112 | 112 | return $this; | 
| 113 | 113 | } | 
| @@ -119,10 +119,10 @@ discard block | ||
| 119 | 119 | * @param string|null $default | 
| 120 | 120 | * @return Column | 
| 121 | 121 | */ | 
| 122 | -	public function datetime( ?string $default = null ): Column { | |
| 123 | - $this->type( 'datetime' ); | |
| 124 | -		if ( null !== $default ) { | |
| 125 | - $this->default( $default ); | |
| 122 | +	public function datetime(?string $default = null): Column { | |
| 123 | +		$this->type('datetime'); | |
| 124 | +		if (null !== $default) { | |
| 125 | + $this->default($default); | |
| 126 | 126 | } | 
| 127 | 127 | return $this; | 
| 128 | 128 | } | 
| @@ -134,10 +134,10 @@ discard block | ||
| 134 | 134 | * @param string|null $default | 
| 135 | 135 | * @return Column | 
| 136 | 136 | */ | 
| 137 | -	public function timestamp( ?string $default = null ): Column { | |
| 138 | - $this->type( 'timestamp' ); | |
| 139 | -		if ( null !== $default ) { | |
| 140 | - $this->default( $default ); | |
| 137 | +	public function timestamp(?string $default = null): Column { | |
| 138 | +		$this->type('timestamp'); | |
| 139 | +		if (null !== $default) { | |
| 140 | + $this->default($default); | |
| 141 | 141 | } | 
| 142 | 142 | return $this; | 
| 143 | 143 | } | 
| @@ -149,11 +149,11 @@ discard block | ||
| 149 | 149 | * @param int|null $length | 
| 150 | 150 | * @return Column | 
| 151 | 151 | */ | 
| 152 | -	public function unsigned_int( ?int $length = null ): Column { | |
| 153 | - $this->type( 'int' ); | |
| 152 | +	public function unsigned_int(?int $length = null): Column { | |
| 153 | +		$this->type('int'); | |
| 154 | 154 | $this->unsigned(); | 
| 155 | -		if ( null !== $length ) { | |
| 156 | - $this->length( $length ); | |
| 155 | +		if (null !== $length) { | |
| 156 | + $this->length($length); | |
| 157 | 157 | } | 
| 158 | 158 | return $this; | 
| 159 | 159 | } | 
| @@ -165,11 +165,11 @@ discard block | ||
| 165 | 165 | * @param int|null $length | 
| 166 | 166 | * @return Column | 
| 167 | 167 | */ | 
| 168 | -	public function unsigned_medium( ?int $length = null ): Column { | |
| 169 | - $this->type( 'mediumint' ); | |
| 168 | +	public function unsigned_medium(?int $length = null): Column { | |
| 169 | +		$this->type('mediumint'); | |
| 170 | 170 | $this->unsigned(); | 
| 171 | -		if ( null !== $length ) { | |
| 172 | - $this->length( $length ); | |
| 171 | +		if (null !== $length) { | |
| 172 | + $this->length($length); | |
| 173 | 173 | } | 
| 174 | 174 | return $this; | 
| 175 | 175 | } | 
| @@ -181,7 +181,7 @@ discard block | ||
| 181 | 181 | * @return Column | 
| 182 | 182 | */ | 
| 183 | 183 |  	public function json(): Column { | 
| 184 | - $this->type( 'json' ); | |
| 184 | +		$this->type('json'); | |
| 185 | 185 | return $this; | 
| 186 | 186 | } | 
| 187 | 187 | } | 
| @@ -100,7 +100,7 @@ discard block | ||
| 100 | 100 | */ | 
| 101 | 101 | protected $unsigned = null; | 
| 102 | 102 | |
| 103 | -	public function __construct( string $name ) { | |
| 103 | +	public function __construct(string $name) { | |
| 104 | 104 | $this->name = $name; | 
| 105 | 105 | } | 
| 106 | 106 | |
| @@ -110,7 +110,7 @@ discard block | ||
| 110 | 110 | * @param string $type | 
| 111 | 111 | * @return self | 
| 112 | 112 | */ | 
| 113 | -	public function type( string $type ): self { | |
| 113 | +	public function type(string $type): self { | |
| 114 | 114 | $this->type = $type; | 
| 115 | 115 | return $this; | 
| 116 | 116 | } | 
| @@ -121,7 +121,7 @@ discard block | ||
| 121 | 121 | * @param integer $length | 
| 122 | 122 | * @return self | 
| 123 | 123 | */ | 
| 124 | -	public function length( int $length ): self { | |
| 124 | +	public function length(int $length): self { | |
| 125 | 125 | $this->length = $length; | 
| 126 | 126 | return $this; | 
| 127 | 127 | } | 
| @@ -134,7 +134,7 @@ discard block | ||
| 134 | 134 | * @param integer $precision | 
| 135 | 135 | * @return self | 
| 136 | 136 | */ | 
| 137 | -	public function precision( int $precision ): self { | |
| 137 | +	public function precision(int $precision): self { | |
| 138 | 138 | $this->precision = $precision; | 
| 139 | 139 | return $this; | 
| 140 | 140 | } | 
| @@ -145,7 +145,7 @@ discard block | ||
| 145 | 145 | * @param boolean $nullable | 
| 146 | 146 | * @return self | 
| 147 | 147 | */ | 
| 148 | -	public function nullable( bool $nullable = true ): self { | |
| 148 | +	public function nullable(bool $nullable = true): self { | |
| 149 | 149 | $this->nullable = $nullable; | 
| 150 | 150 | return $this; | 
| 151 | 151 | } | 
| @@ -156,7 +156,7 @@ discard block | ||
| 156 | 156 | * @param mixed $default | 
| 157 | 157 | * @return self | 
| 158 | 158 | */ | 
| 159 | -	public function default( $default ): self { | |
| 159 | +	public function default($default): self { | |
| 160 | 160 | $this->default = $default; | 
| 161 | 161 | return $this; | 
| 162 | 162 | } | 
| @@ -167,7 +167,7 @@ discard block | ||
| 167 | 167 | * @param boolean $auto_increment | 
| 168 | 168 | * @return self | 
| 169 | 169 | */ | 
| 170 | -	public function auto_increment( bool $auto_increment = true ): self { | |
| 170 | +	public function auto_increment(bool $auto_increment = true): self { | |
| 171 | 171 | $this->auto_increment = $auto_increment; | 
| 172 | 172 | return $this; | 
| 173 | 173 | } | 
| @@ -178,7 +178,7 @@ discard block | ||
| 178 | 178 | * @param boolean $unsigned | 
| 179 | 179 | * @return self | 
| 180 | 180 | */ | 
| 181 | -	public function unsigned( bool $unsigned = true ): self { | |
| 181 | +	public function unsigned(bool $unsigned = true): self { | |
| 182 | 182 | $this->unsigned = $unsigned; | 
| 183 | 183 | return $this; | 
| 184 | 184 | } | 
| @@ -67,8 +67,8 @@ discard block | ||
| 67 | 67 | */ | 
| 68 | 68 | protected $primary = false; | 
| 69 | 69 | |
| 70 | -	public function __construct( string $column, ?string $key_name = null ) { | |
| 71 | - $this->key_name = $key_name ?? 'ix_' . $column; | |
| 70 | +	public function __construct(string $column, ?string $key_name = null) { | |
| 71 | + $this->key_name = $key_name ?? 'ix_'.$column; | |
| 72 | 72 | $this->column = $column; | 
| 73 | 73 | } | 
| 74 | 74 | |
| @@ -78,7 +78,7 @@ discard block | ||
| 78 | 78 | * @param bool $primary is primary key | 
| 79 | 79 | * @return self | 
| 80 | 80 | */ | 
| 81 | -	public function primary( bool $primary = true ): self { | |
| 81 | +	public function primary(bool $primary = true): self { | |
| 82 | 82 | $this->primary = $primary; | 
| 83 | 83 | return $this; | 
| 84 | 84 | } | 
| @@ -90,7 +90,7 @@ discard block | ||
| 90 | 90 | * @param boolean $unique | 
| 91 | 91 | * @return self | 
| 92 | 92 | */ | 
| 93 | -	public function unique( bool $unique = true ): self { | |
| 93 | +	public function unique(bool $unique = true): self { | |
| 94 | 94 | $this->unique = $unique; | 
| 95 | 95 | return $this; | 
| 96 | 96 | } | 
| @@ -102,7 +102,7 @@ discard block | ||
| 102 | 102 | * @param boolean $full_text | 
| 103 | 103 | * @return self | 
| 104 | 104 | */ | 
| 105 | -	public function full_text( bool $full_text = true ): self { | |
| 105 | +	public function full_text(bool $full_text = true): self { | |
| 106 | 106 | $this->full_text = $full_text; | 
| 107 | 107 | return $this; | 
| 108 | 108 | } | 
| @@ -174,11 +174,11 @@ discard block | ||
| 174 | 174 | * @return string | 
| 175 | 175 | */ | 
| 176 | 176 |  	public function get_type(): string { | 
| 177 | -		if ( $this->is_primary() ) { | |
| 177 | +		if ($this->is_primary()) { | |
| 178 | 178 | return 'primary'; | 
| 179 | -		} elseif ( $this->is_unique() ) { | |
| 179 | +		} elseif ($this->is_unique()) { | |
| 180 | 180 | return 'unique'; | 
| 181 | -		} elseif ( $this->is_full_text() ) { | |
| 181 | +		} elseif ($this->is_full_text()) { | |
| 182 | 182 | return 'fulltext'; | 
| 183 | 183 |  		} else { | 
| 184 | 184 | return ''; | 
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 | */ | 
| 64 | 64 | protected $schema; | 
| 65 | 65 | |
| 66 | -	public function __construct( \wpdb $wpdb ) { | |
| 66 | +	public function __construct(\wpdb $wpdb) { | |
| 67 | 67 | $this->wpdb = $wpdb; | 
| 68 | 68 | |
| 69 | 69 | // Set the translator and valiator | 
| @@ -78,10 +78,10 @@ discard block | ||
| 78 | 78 | * @return void | 
| 79 | 79 | * @throws WPDB_Validator_Exception if fails validation (code 201) | 
| 80 | 80 | */ | 
| 81 | -	private function set_query_for_create( Schema $schema ): void { | |
| 81 | +	private function set_query_for_create(Schema $schema): void { | |
| 82 | 82 | $this->schema = $schema; | 
| 83 | 83 | |
| 84 | -		if ( ! $this->validator->validate( $schema ) ) { | |
| 84 | +		if ( ! $this->validator->validate($schema)) { | |
| 85 | 85 | throw WPDB_Validator_Exception::failed_validation( | 
| 86 | 86 | $schema, | 
| 87 | 87 | $this->validator->get_errors() | 
| @@ -98,26 +98,26 @@ discard block | ||
| 98 | 98 | * @throws WPDB_Validator_Exception if fails validation (code 201) | 
| 99 | 99 | * @throws Engine_Exception If errors thrown creating table (code 101) | 
| 100 | 100 | */ | 
| 101 | -	public function create_table( Schema $schema ): bool { | |
| 101 | +	public function create_table(Schema $schema): bool { | |
| 102 | 102 | |
| 103 | 103 | // Generate the query from the passed schema. | 
| 104 | - $query = $this->create_table_query( $schema ); | |
| 104 | + $query = $this->create_table_query($schema); | |
| 105 | 105 | |
| 106 | 106 | // Include WP dbDelta. | 
| 107 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 107 | + require_once ABSPATH.'wp-admin/includes/upgrade.php'; | |
| 108 | 108 | |
| 109 | 109 | \ob_start(); | 
| 110 | - dbDelta( $query ); | |
| 110 | + dbDelta($query); | |
| 111 | 111 | $output = \ob_get_clean(); | 
| 112 | 112 | |
| 113 | 113 | // If output captured, throw. | 
| 114 | -		if ( '' !== $output ) { | |
| 115 | - throw Engine_Exception::create_table( $schema, $output ?: '' ); | |
| 114 | +		if ('' !== $output) { | |
| 115 | + throw Engine_Exception::create_table($schema, $output ?: ''); | |
| 116 | 116 | } | 
| 117 | 117 | |
| 118 | 118 | // Throw if WPDB has errors. | 
| 119 | -		if ( '' !== $this->wpdb->last_error ) { | |
| 120 | - throw Engine_Exception::create_table( $schema, $this->wpdb->last_error ); | |
| 119 | +		if ('' !== $this->wpdb->last_error) { | |
| 120 | + throw Engine_Exception::create_table($schema, $this->wpdb->last_error); | |
| 121 | 121 | } | 
| 122 | 122 | |
| 123 | 123 | return true; | 
| @@ -130,8 +130,8 @@ discard block | ||
| 130 | 130 | * @return string | 
| 131 | 131 | * @throws WPDB_Validator_Exception if fails validation (code 201) | 
| 132 | 132 | */ | 
| 133 | -	public function create_table_query( Schema $schema ): string { | |
| 134 | - $this->set_query_for_create( $schema ); | |
| 133 | +	public function create_table_query(Schema $schema): string { | |
| 134 | + $this->set_query_for_create($schema); | |
| 135 | 135 | return $this->compile_create_sql_query(); | 
| 136 | 136 | } | 
| 137 | 137 | |
| @@ -142,11 +142,11 @@ discard block | ||
| 142 | 142 | * @return void | 
| 143 | 143 | * @throws WPDB_Validator_Exception If fails schema validation (code 201) | 
| 144 | 144 | */ | 
| 145 | -	private function set_query_for_drop( Schema $schema ): void { | |
| 145 | +	private function set_query_for_drop(Schema $schema): void { | |
| 146 | 146 | $this->schema = $schema; | 
| 147 | 147 | |
| 148 | -		if ( ! $this->validator->validate( $schema ) ) { | |
| 149 | - throw WPDB_Validator_Exception::failed_validation( $schema, $this->validator->get_errors() ); | |
| 148 | +		if ( ! $this->validator->validate($schema)) { | |
| 149 | + throw WPDB_Validator_Exception::failed_validation($schema, $this->validator->get_errors()); | |
| 150 | 150 | } | 
| 151 | 151 | } | 
| 152 | 152 | |
| @@ -158,22 +158,22 @@ discard block | ||
| 158 | 158 | * @throws WPDB_Validator_Exception If fails schema validation (code 201) | 
| 159 | 159 | * @throws Engine_Exception If error thrown dropping table. (code 102) | 
| 160 | 160 | */ | 
| 161 | -	public function drop_table( Schema $schema ): bool { | |
| 161 | +	public function drop_table(Schema $schema): bool { | |
| 162 | 162 | |
| 163 | - $query = $this->drop_table_query( $schema ); | |
| 163 | + $query = $this->drop_table_query($schema); | |
| 164 | 164 | |
| 165 | 165 | \ob_start(); | 
| 166 | - $this->wpdb->get_results( $query ); // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared | |
| 166 | + $this->wpdb->get_results($query); // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared | |
| 167 | 167 | $output = \ob_get_clean(); | 
| 168 | 168 | |
| 169 | 169 | // If output captured, throw. | 
| 170 | -		if ( '' !== $output ) { | |
| 171 | - throw Engine_Exception::drop_table( $schema, $output ?: '' ); | |
| 170 | +		if ('' !== $output) { | |
| 171 | + throw Engine_Exception::drop_table($schema, $output ?: ''); | |
| 172 | 172 | } | 
| 173 | 173 | |
| 174 | 174 | // Throw if WPDB has errors. | 
| 175 | -		if ( '' !== $this->wpdb->last_error ) { | |
| 176 | - throw Engine_Exception::drop_table( $schema, $this->wpdb->last_error ); | |
| 175 | +		if ('' !== $this->wpdb->last_error) { | |
| 176 | + throw Engine_Exception::drop_table($schema, $this->wpdb->last_error); | |
| 177 | 177 | } | 
| 178 | 178 | |
| 179 | 179 | return true; | 
| @@ -186,8 +186,8 @@ discard block | ||
| 186 | 186 | * @return string | 
| 187 | 187 | * @throws WPDB_Validator_Exception If fails schema validation (code 201) | 
| 188 | 188 | */ | 
| 189 | -	public function drop_table_query( Schema $schema ): string { | |
| 190 | - $this->set_query_for_drop( $schema ); | |
| 189 | +	public function drop_table_query(Schema $schema): string { | |
| 190 | + $this->set_query_for_drop($schema); | |
| 191 | 191 |  		return "DROP TABLE IF EXISTS {$this->schema->get_table_name()};"; | 
| 192 | 192 | } | 
| 193 | 193 | |
| @@ -201,10 +201,10 @@ discard block | ||
| 201 | 201 | // Compile query partials. | 
| 202 | 202 | $table = $this->schema->get_table_name(); | 
| 203 | 203 | $body = join( | 
| 204 | - ',' . PHP_EOL, | |
| 204 | + ','.PHP_EOL, | |
| 205 | 205 | array_merge( | 
| 206 | - $this->translator->translate_columns( $this->schema ), | |
| 207 | - $this->translator->translate_indexes( $this->schema ) | |
| 206 | + $this->translator->translate_columns($this->schema), | |
| 207 | + $this->translator->translate_indexes($this->schema) | |
| 208 | 208 | ) | 
| 209 | 209 | ); | 
| 210 | 210 | $collate = $this->wpdb->collate; |