Code Duplication    Length = 10-11 lines in 2 locations

src/DB/Reports.php 2 locations

@@ 104-114 (lines=11) @@
101
		$wpdb->show_errors();
102
		$db = new Database( $wpdb );
103
104
		if ( ! $db->get_table( self::reports_table_name() ) ) {
105
			$sql = "CREATE TABLE IF NOT EXISTS `" . self::reports_table_name() . "` (
106
				`id` INT(4) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
107
				`title` varchar(191) NOT NULL UNIQUE,
108
				`description` text NOT NULL,
109
				`mime_type` varchar(50) NOT NULL DEFAULT 'text/html',
110
				`file_extension` varchar(10) DEFAULT NULL COMMENT 'If defined, this report will be downloaded.',
111
				`template` text NOT NULL COMMENT 'The Twig template used to display this report.'
112
				) ENGINE=InnoDB;";
113
			$wpdb->query( $sql );
114
		}
115
		// Reduce length of title column to floor(767/4) = 191 characters. GH60.
116
		$title_size = $db->get_table( self::reports_table_name() )->get_column( 'title' )->get_size();
117
		if ( $title_size == 200 ) {
@@ 121-130 (lines=10) @@
118
			$wpdb->query( "ALTER TABLE `" . self::reports_table_name() . "` MODIFY `title` VARCHAR(191) NOT NULL" );
119
		}
120
121
		if ( ! $db->get_table( self::report_sources_table_name() ) ) {
122
			$sql = "CREATE TABLE IF NOT EXISTS `" . self::report_sources_table_name() . "` (
123
				`id` INT(5) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
124
				`report` INT(4) unsigned NOT NULL,
125
						FOREIGN KEY (`report`) REFERENCES `" . self::reports_table_name() . "` (`id`),
126
				`name` varchar(50) NOT NULL,
127
				`query` text NOT NULL
128
				) ENGINE=InnoDB;";
129
			$wpdb->query( $sql );
130
		}
131
132
		if ( '0' === $wpdb->get_var( "SELECT COUNT(*) FROM `" . self::reports_table_name() . "`" ) ) {
133
			// Create the default report, to list all reports.