Edit File by line
/home/barbar84/www/wp-conte.../plugins/wordpres.../lib/migratio...
File: column.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\Lib\Migrations;
[2] Fix | Delete
[3] Fix | Delete
use Exception;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Yoast migrations column class.
[7] Fix | Delete
*/
[8] Fix | Delete
class Column {
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* The adapter.
[12] Fix | Delete
*
[13] Fix | Delete
* @var Adapter
[14] Fix | Delete
*/
[15] Fix | Delete
private $adapter;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* The name.
[19] Fix | Delete
*
[20] Fix | Delete
* @var string
[21] Fix | Delete
*/
[22] Fix | Delete
public $name;
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* The type.
[26] Fix | Delete
*
[27] Fix | Delete
* @var mixed
[28] Fix | Delete
*/
[29] Fix | Delete
public $type;
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* The properties.
[33] Fix | Delete
*
[34] Fix | Delete
* @var mixed
[35] Fix | Delete
*/
[36] Fix | Delete
public $properties;
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* The options.
[40] Fix | Delete
*
[41] Fix | Delete
* @var array
[42] Fix | Delete
*/
[43] Fix | Delete
private $options = [];
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Creates an instance of a column.
[47] Fix | Delete
*
[48] Fix | Delete
* @param Adapter $adapter The current adapter.
[49] Fix | Delete
* @param string $name The name of the column.
[50] Fix | Delete
* @param string $type The type of the column.
[51] Fix | Delete
* @param array $options The column options.
[52] Fix | Delete
*
[53] Fix | Delete
* @throws Exception If invalid arguments provided.
[54] Fix | Delete
*/
[55] Fix | Delete
public function __construct( $adapter, $name, $type, $options = [] ) {
[56] Fix | Delete
if ( ! $adapter instanceof Adapter ) {
[57] Fix | Delete
throw new Exception( 'Invalid Adapter instance.' );
[58] Fix | Delete
}
[59] Fix | Delete
if ( empty( $name ) || ! \is_string( $name ) ) {
[60] Fix | Delete
throw new Exception( "Invalid 'name' parameter" );
[61] Fix | Delete
}
[62] Fix | Delete
if ( empty( $type ) || ! \is_string( $type ) ) {
[63] Fix | Delete
throw new Exception( "Invalid 'type' parameter" );
[64] Fix | Delete
}
[65] Fix | Delete
$this->adapter = $adapter;
[66] Fix | Delete
$this->name = $name;
[67] Fix | Delete
$this->type = $type;
[68] Fix | Delete
$this->options = $options;
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Returns the SQL of this column.
[73] Fix | Delete
*
[74] Fix | Delete
* @return string
[75] Fix | Delete
*/
[76] Fix | Delete
public function to_sql() {
[77] Fix | Delete
$column_sql = \sprintf( '%s %s', $this->adapter->identifier( $this->name ), $this->sql_type() );
[78] Fix | Delete
$column_sql .= $this->adapter->add_column_options( $this->type, $this->options );
[79] Fix | Delete
return $column_sql;
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
/**
[83] Fix | Delete
* The SQL string version.
[84] Fix | Delete
*
[85] Fix | Delete
* @return string
[86] Fix | Delete
*/
[87] Fix | Delete
public function __toString() {
[88] Fix | Delete
return $this->to_sql();
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
/**
[92] Fix | Delete
* The SQL type.
[93] Fix | Delete
*
[94] Fix | Delete
* @return string
[95] Fix | Delete
*/
[96] Fix | Delete
private function sql_type() {
[97] Fix | Delete
return $this->adapter->type_to_sql( $this->type, $this->options );
[98] Fix | Delete
}
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function