Completed
Push — master ( f4362b...61d821 )
by
unknown
01:43
created
includes/CrossCheck/Comparer/StringComparer.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 */
23 23
 	private $stringNormalizer;
24 24
 
25
-	public function __construct( StringNormalizer $stringNormalizer ) {
25
+	public function __construct(StringNormalizer $stringNormalizer) {
26 26
 		$this->stringNormalizer = $stringNormalizer;
27 27
 	}
28 28
 
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
 	 * @param string $comparativeValue
34 34
 	 * @return string
35 35
 	 */
36
-	public function compare( $value, $comparativeValue ) {
37
-		Assert::parameterType( 'string', $value, '$value' );
38
-		Assert::parameterType( 'string', $comparativeValue, '$comparativeValue' );
36
+	public function compare($value, $comparativeValue) {
37
+		Assert::parameterType('string', $value, '$value');
38
+		Assert::parameterType('string', $comparativeValue, '$comparativeValue');
39 39
 
40
-		$value = $this->cleanDataString( $value );
41
-		$comparativeValue = $this->cleanDataString( $comparativeValue );
40
+		$value = $this->cleanDataString($value);
41
+		$comparativeValue = $this->cleanDataString($comparativeValue);
42 42
 
43
-		if ( $value === $comparativeValue ) {
43
+		if ($value === $comparativeValue) {
44 44
 			return ComparisonResult::STATUS_MATCH;
45
-		} elseif ( $this->checkSimilarity( $value, $comparativeValue ) ) {
45
+		} elseif ($this->checkSimilarity($value, $comparativeValue)) {
46 46
 			return ComparisonResult::STATUS_PARTIAL_MATCH;
47 47
 		} else {
48 48
 			return ComparisonResult::STATUS_MISMATCH;
@@ -56,19 +56,19 @@  discard block
 block discarded – undo
56 56
 	 * @param string[] $comparativeValues
57 57
 	 * @return string
58 58
 	 */
59
-	public function compareWithArray( $value, array $comparativeValues ) {
60
-		Assert::parameterType( 'string', $value, '$value' );
61
-		Assert::parameterElementType( 'string', $comparativeValues, '$comparativeValues' );
59
+	public function compareWithArray($value, array $comparativeValues) {
60
+		Assert::parameterType('string', $value, '$value');
61
+		Assert::parameterElementType('string', $comparativeValues, '$comparativeValues');
62 62
 
63
-		$value = $this->cleanDataString( $value );
64
-		$comparativeValues = $this->cleanDataArray( $comparativeValues );
63
+		$value = $this->cleanDataString($value);
64
+		$comparativeValues = $this->cleanDataArray($comparativeValues);
65 65
 
66
-		if ( in_array( $value, $comparativeValues ) ) {
66
+		if (in_array($value, $comparativeValues)) {
67 67
 			return ComparisonResult::STATUS_MATCH;
68 68
 		}
69 69
 
70
-		foreach ( $comparativeValues as $comparativeValue ) {
71
-			if ( $this->checkSimilarity( $comparativeValue, $value ) ) {
70
+		foreach ($comparativeValues as $comparativeValue) {
71
+			if ($this->checkSimilarity($comparativeValue, $value)) {
72 72
 				return ComparisonResult::STATUS_PARTIAL_MATCH;
73 73
 			}
74 74
 		}
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 	 * @param string $comparativeValue
84 84
 	 * @return bool
85 85
 	 */
86
-	private function checkSimilarity( $value, $comparativeValue ) {
87
-		return $this->percentagePrefixSimilarity( $value, $comparativeValue ) > self::SIMILARITY_THRESHOLD
88
-			|| $this->percentageSuffixSimilarity( $value, $comparativeValue ) > self::SIMILARITY_THRESHOLD
89
-			|| $this->percentageLevenshteinDistance( $value, $comparativeValue ) > self::SIMILARITY_THRESHOLD;
86
+	private function checkSimilarity($value, $comparativeValue) {
87
+		return $this->percentagePrefixSimilarity($value, $comparativeValue) > self::SIMILARITY_THRESHOLD
88
+			|| $this->percentageSuffixSimilarity($value, $comparativeValue) > self::SIMILARITY_THRESHOLD
89
+			|| $this->percentageLevenshteinDistance($value, $comparativeValue) > self::SIMILARITY_THRESHOLD;
90 90
 	}
91 91
 
92 92
 	/**
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @return string
98 98
 	 */
99
-	private function cleanDataString( $value ) {
100
-		$value = $this->stringNormalizer->trimToNFC( $value );
99
+	private function cleanDataString($value) {
100
+		$value = $this->stringNormalizer->trimToNFC($value);
101 101
 
102
-		return mb_strtolower( $value );
102
+		return mb_strtolower($value);
103 103
 	}
104 104
 
105 105
 	/**
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return string[]
111 111
 	 */
112
-	private function cleanDataArray( array $array ) {
112
+	private function cleanDataArray(array $array) {
113 113
 		return array_map(
114
-			[ $this, 'cleanDataString' ],
114
+			[$this, 'cleanDataString'],
115 115
 			$array );
116 116
 	}
117 117
 
@@ -123,19 +123,19 @@  discard block
 block discarded – undo
123 123
 	 *
124 124
 	 * @return float
125 125
 	 */
126
-	private function percentagePrefixSimilarity( $value, $comparativeValue ) {
126
+	private function percentagePrefixSimilarity($value, $comparativeValue) {
127 127
 		$prefixLength = 0; // common prefix length
128
-		$localLength = strlen( $value );
129
-		$externalLength = strlen( $comparativeValue );
130
-		while ( $prefixLength < min( $localLength, $externalLength ) ) {
128
+		$localLength = strlen($value);
129
+		$externalLength = strlen($comparativeValue);
130
+		while ($prefixLength < min($localLength, $externalLength)) {
131 131
 			$c = $value[$prefixLength];
132
-			if ( $externalLength > $prefixLength && $comparativeValue[$prefixLength] !== $c ) {
132
+			if ($externalLength > $prefixLength && $comparativeValue[$prefixLength] !== $c) {
133 133
 				break;
134 134
 			}
135 135
 			$prefixLength++;
136 136
 		}
137 137
 
138
-		return $prefixLength / max( $localLength, $externalLength );
138
+		return $prefixLength / max($localLength, $externalLength);
139 139
 	}
140 140
 
141 141
 	/**
@@ -146,19 +146,19 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return float
148 148
 	 */
149
-	private function percentageSuffixSimilarity( $value, $comparativeValue ) {
149
+	private function percentageSuffixSimilarity($value, $comparativeValue) {
150 150
 		$suffixLength = 0; // common suffix length
151
-		$localLength = strlen( $value );
152
-		$externalLength = strlen( $comparativeValue );
153
-		while ( $suffixLength < min( $localLength, $externalLength ) ) {
151
+		$localLength = strlen($value);
152
+		$externalLength = strlen($comparativeValue);
153
+		while ($suffixLength < min($localLength, $externalLength)) {
154 154
 			$c = $value[$localLength - 1 - $suffixLength];
155
-			if ( $externalLength > $suffixLength && $comparativeValue[$externalLength - 1 - $suffixLength] !== $c ) {
155
+			if ($externalLength > $suffixLength && $comparativeValue[$externalLength - 1 - $suffixLength] !== $c) {
156 156
 				break;
157 157
 			}
158 158
 			$suffixLength++;
159 159
 		}
160 160
 
161
-		return $suffixLength / max( $localLength, $externalLength );
161
+		return $suffixLength / max($localLength, $externalLength);
162 162
 	}
163 163
 
164 164
 	/**
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @return float
171 171
 	 */
172
-	private function percentageLevenshteinDistance( $value, $comparativeValue ) {
173
-		$distance = levenshtein( $value, $comparativeValue );
174
-		$percentage = 1.0 - $distance / max( strlen( $value ), strlen( $comparativeValue ) );
172
+	private function percentageLevenshteinDistance($value, $comparativeValue) {
173
+		$distance = levenshtein($value, $comparativeValue);
174
+		$percentage = 1.0 - $distance / max(strlen($value), strlen($comparativeValue));
175 175
 
176 176
 		return $percentage;
177 177
 	}
Please login to merge, or discard this patch.
includes/UpdateExternalData/ExternalDataImporter.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
 	public function import() {
48 48
 		$dumpIds = $this->insertMetaInformation();
49 49
 
50
-		$this->log( "\nDelete old database entries...\n" );
50
+		$this->log("\nDelete old database entries...\n");
51 51
 
52
-		foreach ( $dumpIds as $dumpId ) {
53
-			$this->externalDataRepo->deleteOfDump( $dumpId, $this->importSettings->getBatchSize() );
52
+		foreach ($dumpIds as $dumpId) {
53
+			$this->externalDataRepo->deleteOfDump($dumpId, $this->importSettings->getBatchSize());
54 54
 		}
55 55
 
56
-		$this->log( "\n" );
56
+		$this->log("\n");
57 57
 
58 58
 		$this->insertExternalValues();
59 59
 	}
@@ -64,52 +64,52 @@  discard block
 block discarded – undo
64 64
 	 * @return string[]
65 65
 	 */
66 66
 	protected function insertMetaInformation() {
67
-		$this->log( "Insert new dump meta information\n" );
67
+		$this->log("Insert new dump meta information\n");
68 68
 
69
-		$csvFile = fopen( $this->importSettings->getDumpInformationFilePath(), 'rb' );
70
-		if ( !$csvFile ) {
71
-			exit( 'Error while reading CSV file.' );
69
+		$csvFile = fopen($this->importSettings->getDumpInformationFilePath(), 'rb');
70
+		if (!$csvFile) {
71
+			exit('Error while reading CSV file.');
72 72
 		}
73 73
 
74 74
 		$i = 0;
75 75
 		$dumpIds = [];
76
-		while ( $data = fgetcsv( $csvFile ) ) {
76
+		while ($data = fgetcsv($csvFile)) {
77 77
 			$identifierPropertyIds = array_map(
78
-				function ( $propertyId ) {
79
-					return new PropertyId( $propertyId );
78
+				function($propertyId) {
79
+					return new PropertyId($propertyId);
80 80
 				},
81
-				json_decode( $data[2] )
81
+				json_decode($data[2])
82 82
 			);
83 83
 			try {
84 84
 				$dumpMetaInformation = new DumpMetaInformation(
85 85
 					$data[0],
86
-					new ItemId( $data[1] ),
86
+					new ItemId($data[1]),
87 87
 					$identifierPropertyIds,
88 88
 					$data[3],
89 89
 					$data[4],
90 90
 					$data[5],
91
-					intval( $data[6] ),
92
-					new ItemId( $data[7] )
91
+					intval($data[6]),
92
+					new ItemId($data[7])
93 93
 				);
94
-			} catch ( \InvalidArgumentException $e ) {
95
-				exit( 'Input file has bad formatted values.' );
94
+			} catch (\InvalidArgumentException $e) {
95
+				exit('Input file has bad formatted values.');
96 96
 			}
97 97
 			$dumpIds[] = $dumpMetaInformation->getDumpId();
98 98
 
99 99
 			try {
100
-				$this->dumpMetaInformationStore->save( $dumpMetaInformation );
101
-			} catch ( DBError $e ) {
102
-				exit( 'Unknown database error occurred.' );
100
+				$this->dumpMetaInformationStore->save($dumpMetaInformation);
101
+			} catch (DBError $e) {
102
+				exit('Unknown database error occurred.');
103 103
 			}
104 104
 
105 105
 			$i++;
106
-			$this->log( "\r\033[K" );
107
-			$this->log( "$i rows inserted or updated" );
106
+			$this->log("\r\033[K");
107
+			$this->log("$i rows inserted or updated");
108 108
 		}
109 109
 
110
-		fclose( $csvFile );
110
+		fclose($csvFile);
111 111
 
112
-		$this->log( "\n" );
112
+		$this->log("\n");
113 113
 
114 114
 		return $dumpIds;
115 115
 	}
@@ -118,32 +118,32 @@  discard block
 block discarded – undo
118 118
 	 * Inserts external values stored in csv file into database
119 119
 	 */
120 120
 	private function insertExternalValues() {
121
-		$this->log( "Insert new data values\n" );
121
+		$this->log("Insert new data values\n");
122 122
 
123
-		$csvFile = fopen( $this->importSettings->getExternalValuesFilePath(), 'rb' );
124
-		if ( !$csvFile ) {
125
-			exit( 'Error while reading CSV file.' );
123
+		$csvFile = fopen($this->importSettings->getExternalValuesFilePath(), 'rb');
124
+		if (!$csvFile) {
125
+			exit('Error while reading CSV file.');
126 126
 		}
127 127
 
128 128
 		$i = 0;
129 129
 		$accumulator = [];
130 130
 		$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
131
-		while ( true ) {
132
-			$data = fgetcsv( $csvFile );
133
-			if ( $data === false || ++$i % $this->importSettings->getBatchSize() === 0 ) {
131
+		while (true) {
132
+			$data = fgetcsv($csvFile);
133
+			if ($data === false || ++$i % $this->importSettings->getBatchSize() === 0) {
134 134
 				try {
135
-					$this->externalDataRepo->insertBatch( $accumulator );
136
-				} catch ( DBError $e ) {
137
-					exit( 'Unknown database error occurred.' );
135
+					$this->externalDataRepo->insertBatch($accumulator);
136
+				} catch (DBError $e) {
137
+					exit('Unknown database error occurred.');
138 138
 				}
139 139
 				$lbFactory->waitForReplication();
140 140
 
141
-				$this->log( "\r\033[K" );
142
-				$this->log( "$i rows inserted" );
141
+				$this->log("\r\033[K");
142
+				$this->log("$i rows inserted");
143 143
 
144 144
 				$accumulator = [];
145 145
 
146
-				if ( $data === false ) {
146
+				if ($data === false) {
147 147
 					break;
148 148
 				}
149 149
 			}
@@ -151,16 +151,16 @@  discard block
 block discarded – undo
151 151
 			$accumulator[] = $data;
152 152
 		}
153 153
 
154
-		fclose( $csvFile );
154
+		fclose($csvFile);
155 155
 
156
-		$this->log( "\n" );
156
+		$this->log("\n");
157 157
 	}
158 158
 
159 159
 	/**
160 160
 	 * @param string $text
161 161
 	 */
162
-	private function log( $text ) {
163
-		if ( !$this->importSettings->isQuiet() ) {
162
+	private function log($text) {
163
+		if (!$this->importSettings->isQuiet()) {
164 164
 			print $text;
165 165
 		}
166 166
 	}
Please login to merge, or discard this patch.
specials/SpecialExternalDatabases.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		EntityIdHtmlLinkFormatterFactory $entityIdHtmlLinkFormatterFactory,
50 50
 		DumpMetaInformationLookup $dumpMetaInformationRepo
51 51
 	) {
52
-		parent::__construct( 'ExternalDatabases' );
52
+		parent::__construct('ExternalDatabases');
53 53
 
54 54
 		$this->entityIdLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter(
55 55
 			$this->getLanguage()
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @return string
74 74
 	 */
75 75
 	public function getDescription() {
76
-		return $this->msg( 'wbqev-externaldbs' )->text();
76
+		return $this->msg('wbqev-externaldbs')->text();
77 77
 	}
78 78
 
79 79
 	/**
@@ -81,51 +81,51 @@  discard block
 block discarded – undo
81 81
 	 *
82 82
 	 * @param string|null $subPage
83 83
 	 */
84
-	public function execute( $subPage ) {
84
+	public function execute($subPage) {
85 85
 		$out = $this->getOutput();
86 86
 
87 87
 		$this->setHeaders();
88 88
 
89 89
 		$out->addHTML(
90
-			Html::openElement( 'p' )
91
-			. $this->msg( 'wbqev-externaldbs-instructions' )->parse()
92
-			. Html::closeElement( 'p' )
93
-			. Html::openElement( 'h3' )
94
-			. $this->msg( 'wbqev-externaldbs-overview-headline' )->parse()
95
-			. Html::closeElement( 'h3' )
90
+			Html::openElement('p')
91
+			. $this->msg('wbqev-externaldbs-instructions')->parse()
92
+			. Html::closeElement('p')
93
+			. Html::openElement('h3')
94
+			. $this->msg('wbqev-externaldbs-overview-headline')->parse()
95
+			. Html::closeElement('h3')
96 96
 		);
97 97
 
98 98
 		$dumps = $this->dumpMetaInformationRepo->getAll();
99
-		if ( $dumps !== [] ) {
99
+		if ($dumps !== []) {
100 100
 			$groupedDumpMetaInformation = [];
101
-			foreach ( $dumps as $dump ) {
101
+			foreach ($dumps as $dump) {
102 102
 				$sourceItemId = $dump->getSourceItemId()->getSerialization();
103 103
 				$groupedDumpMetaInformation[$sourceItemId][] = $dump;
104 104
 			}
105 105
 
106 106
 			$table = new HtmlTableBuilder(
107 107
 				[
108
-					$this->msg( 'wbqev-externaldbs-name' )->escaped(),
109
-					$this->msg( 'wbqev-externaldbs-id' )->escaped(),
110
-					$this->msg( 'wbqev-externaldbs-import-date' )->escaped(),
111
-					$this->msg( 'wbqev-externaldbs-language' )->escaped(),
112
-					$this->msg( 'wbqev-externaldbs-source-urls' )->escaped(),
113
-					$this->msg( 'wbqev-externaldbs-size' )->escaped(),
114
-					$this->msg( 'wbqev-externaldbs-license' )->escaped()
108
+					$this->msg('wbqev-externaldbs-name')->escaped(),
109
+					$this->msg('wbqev-externaldbs-id')->escaped(),
110
+					$this->msg('wbqev-externaldbs-import-date')->escaped(),
111
+					$this->msg('wbqev-externaldbs-language')->escaped(),
112
+					$this->msg('wbqev-externaldbs-source-urls')->escaped(),
113
+					$this->msg('wbqev-externaldbs-size')->escaped(),
114
+					$this->msg('wbqev-externaldbs-license')->escaped()
115 115
 				],
116 116
 				true
117 117
 			);
118 118
 
119
-			foreach ( $groupedDumpMetaInformation as $dumpMetaInformation ) {
120
-				$table->appendRows( $this->getRowGroup( $dumpMetaInformation ) );
119
+			foreach ($groupedDumpMetaInformation as $dumpMetaInformation) {
120
+				$table->appendRows($this->getRowGroup($dumpMetaInformation));
121 121
 			}
122 122
 
123
-			$out->addHTML( $table->toHtml() );
123
+			$out->addHTML($table->toHtml());
124 124
 		} else {
125 125
 			$out->addHTML(
126
-				Html::openElement( 'p' )
127
-				. $this->msg( 'wbqev-externaldbs-no-databases' )->escaped()
128
-				. Html::closeElement( 'p' )
126
+				Html::openElement('p')
127
+				. $this->msg('wbqev-externaldbs-no-databases')->escaped()
128
+				. Html::closeElement('p')
129 129
 			);
130 130
 		}
131 131
 	}
@@ -137,12 +137,12 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return array[]
139 139
 	 */
140
-	private function getRowGroup( array $dumpMetaInformationGroup ) {
140
+	private function getRowGroup(array $dumpMetaInformationGroup) {
141 141
 		$rows = [];
142 142
 
143
-		foreach ( $dumpMetaInformationGroup as $dumpMetaInformation ) {
143
+		foreach ($dumpMetaInformationGroup as $dumpMetaInformation) {
144 144
 			$dumpId = $dumpMetaInformation->getDumpId();
145
-			$importDate = $this->getLanguage()->timeanddate( $dumpMetaInformation->getImportDate() );
145
+			$importDate = $this->getLanguage()->timeanddate($dumpMetaInformation->getImportDate());
146 146
 			$language = Language::fetchLanguageName(
147 147
 				$dumpMetaInformation->getLanguageCode(),
148 148
 				$this->getLanguage()->getCode()
@@ -151,23 +151,23 @@  discard block
 block discarded – undo
151 151
 				$dumpMetaInformation->getSourceUrl(),
152 152
 				$dumpMetaInformation->getSourceUrl()
153 153
 			);
154
-			$size = $this->getLanguage()->formatSize( $dumpMetaInformation->getSize() );
155
-			$license = $this->entityIdLinkFormatter->formatEntityId( $dumpMetaInformation->getLicenseItemId() );
154
+			$size = $this->getLanguage()->formatSize($dumpMetaInformation->getSize());
155
+			$license = $this->entityIdLinkFormatter->formatEntityId($dumpMetaInformation->getLicenseItemId());
156 156
 			$rows[] = [
157
-				new HtmlTableCellBuilder( $dumpId ),
158
-				new HtmlTableCellBuilder( $importDate ),
159
-				new HtmlTableCellBuilder( $language ),
160
-				new HtmlTableCellBuilder( $sourceUrl, [], true ),
161
-				new HtmlTableCellBuilder( $size ),
162
-				new HtmlTableCellBuilder( $license, [], true )
157
+				new HtmlTableCellBuilder($dumpId),
158
+				new HtmlTableCellBuilder($importDate),
159
+				new HtmlTableCellBuilder($language),
160
+				new HtmlTableCellBuilder($sourceUrl, [], true),
161
+				new HtmlTableCellBuilder($size),
162
+				new HtmlTableCellBuilder($license, [], true)
163 163
 			];
164 164
 		}
165 165
 
166 166
 		array_unshift(
167 167
 			$rows[0],
168 168
 			new HtmlTableCellBuilder(
169
-				$this->entityIdLinkFormatter->formatEntityId( $dumpMetaInformationGroup[0]->getSourceItemId() ),
170
-				[ 'rowspan' => (string)count( $dumpMetaInformationGroup ) ],
169
+				$this->entityIdLinkFormatter->formatEntityId($dumpMetaInformationGroup[0]->getSourceItemId()),
170
+				['rowspan' => (string)count($dumpMetaInformationGroup)],
171 171
 				true
172 172
 			)
173 173
 		);
Please login to merge, or discard this patch.
specials/SpecialCrossCheck.php 1 patch
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
 		OutputFormatValueFormatterFactory $valueFormatterFactory,
95 95
 		CrossCheckInteractor $crossCheckInteractor
96 96
 	) {
97
-		parent::__construct( 'CrossCheck' );
97
+		parent::__construct('CrossCheck');
98 98
 
99 99
 		$this->entityLookup = $entityLookup;
100 100
 		$this->entityIdParser = $entityIdParser;
101 101
 
102 102
 		$formatterOptions = new FormatterOptions();
103
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $this->getLanguage()->getCode() );
104
-		$this->dataValueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
103
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $this->getLanguage()->getCode());
104
+		$this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
105 105
 
106
-		$this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $this->getLanguage() );
107
-		$this->entityIdLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $this->getLanguage() );
106
+		$this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($this->getLanguage());
107
+		$this->entityIdLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($this->getLanguage());
108 108
 
109 109
 		$this->crossCheckInteractor = $crossCheckInteractor;
110 110
 	}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @return string (plain text)
125 125
 	 */
126 126
 	public function getDescription() {
127
-		return $this->msg( 'wbqev-crosscheck' )->text();
127
+		return $this->msg('wbqev-crosscheck')->text();
128 128
 	}
129 129
 
130 130
 	/**
@@ -136,55 +136,55 @@  discard block
 block discarded – undo
136 136
 	 * @throws EntityIdParsingException
137 137
 	 * @throws UnexpectedValueException
138 138
 	 */
139
-	public function execute( $subPage ) {
139
+	public function execute($subPage) {
140 140
 		$out = $this->getOutput();
141
-		$postRequest = $this->getContext()->getRequest()->getVal( 'entityid' );
142
-		if ( $postRequest ) {
143
-			$out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() );
141
+		$postRequest = $this->getContext()->getRequest()->getVal('entityid');
142
+		if ($postRequest) {
143
+			$out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL());
144 144
 			return;
145 145
 		}
146 146
 
147
-		$out->addModules( 'SpecialCrossCheckPage' );
147
+		$out->addModules('SpecialCrossCheckPage');
148 148
 
149 149
 		$this->setHeaders();
150 150
 
151
-		$out->addHTML( $this->buildInfoBox() );
151
+		$out->addHTML($this->buildInfoBox());
152 152
 		$this->buildEntityIdForm();
153 153
 
154
-		if ( $subPage ) {
155
-			$this->buildResult( $subPage );
154
+		if ($subPage) {
155
+			$this->buildResult($subPage);
156 156
 		}
157 157
 	}
158 158
 
159 159
 	/**
160 160
 	 * @param string $idSerialization
161 161
 	 */
162
-	private function buildResult( $idSerialization ) {
162
+	private function buildResult($idSerialization) {
163 163
 		$out = $this->getOutput();
164 164
 
165 165
 		try {
166
-			$entityId = $this->entityIdParser->parse( $idSerialization );
167
-		} catch ( EntityIdParsingException $ex ) {
168
-			$out->addHTML( $this->buildNotice( 'wbqev-crosscheck-invalid-entity-id', true ) );
166
+			$entityId = $this->entityIdParser->parse($idSerialization);
167
+		} catch (EntityIdParsingException $ex) {
168
+			$out->addHTML($this->buildNotice('wbqev-crosscheck-invalid-entity-id', true));
169 169
 			return;
170 170
 		}
171 171
 
172
-		$out->addHTML( $this->buildResultHeader( $entityId ) );
172
+		$out->addHTML($this->buildResultHeader($entityId));
173 173
 
174
-		$entity = $this->entityLookup->getEntity( $entityId );
175
-		if ( $entity === null ) {
176
-			$out->addHTML( $this->buildNotice( 'wbqev-crosscheck-not-existent-entity', true ) );
174
+		$entity = $this->entityLookup->getEntity($entityId);
175
+		if ($entity === null) {
176
+			$out->addHTML($this->buildNotice('wbqev-crosscheck-not-existent-entity', true));
177 177
 			return;
178 178
 		}
179 179
 
180
-		$results = $this->getCrossCheckResultsFromEntity( $entity );
180
+		$results = $this->getCrossCheckResultsFromEntity($entity);
181 181
 
182
-		if ( $results === null || $results->toArray() === [] ) {
183
-			$out->addHTML( $this->buildNotice( 'wbqev-crosscheck-empty-result' ) );
182
+		if ($results === null || $results->toArray() === []) {
183
+			$out->addHTML($this->buildNotice('wbqev-crosscheck-empty-result'));
184 184
 		} else {
185 185
 			$out->addHTML(
186
-				$this->buildSummary( $results )
187
-				. $this->buildResultTable( $results )
186
+				$this->buildSummary($results)
187
+				. $this->buildResultTable($results)
188 188
 			);
189 189
 		}
190 190
 	}
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
 	 *
195 195
 	 * @return CrossCheckResultList|null
196 196
 	 */
197
-	private function getCrossCheckResultsFromEntity( EntityDocument $entity ) {
198
-		if ( $entity instanceof StatementListProvider ) {
199
-			return $this->crossCheckInteractor->crossCheckStatements( $entity->getStatements() );
197
+	private function getCrossCheckResultsFromEntity(EntityDocument $entity) {
198
+		if ($entity instanceof StatementListProvider) {
199
+			return $this->crossCheckInteractor->crossCheckStatements($entity->getStatements());
200 200
 		}
201 201
 
202 202
 		return null;
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
 				'name' => 'entityid',
214 214
 				'label-message' => 'wbqev-crosscheck-form-entityid-label',
215 215
 				'cssclass' => 'wbqev-crosscheck-form-entity-id',
216
-				'placeholder' => $this->msg( 'wbqev-crosscheck-form-entityid-placeholder' )->escaped()
216
+				'placeholder' => $this->msg('wbqev-crosscheck-form-entityid-placeholder')->escaped()
217 217
 			]
218 218
 		];
219
-		$htmlForm = new HTMLForm( $formDescriptor, $this->getContext(), 'wbqev-crosscheck-form' );
220
-		$htmlForm->setSubmitText( $this->msg( 'wbqev-crosscheck-form-submit-label' )->escaped() );
221
-		$htmlForm->setSubmitCallback( function() {
219
+		$htmlForm = new HTMLForm($formDescriptor, $this->getContext(), 'wbqev-crosscheck-form');
220
+		$htmlForm->setSubmitText($this->msg('wbqev-crosscheck-form-submit-label')->escaped());
221
+		$htmlForm->setSubmitCallback(function() {
222 222
 			return false;
223 223
 		} );
224
-		$htmlForm->setMethod( 'post' );
224
+		$htmlForm->setMethod('post');
225 225
 		$htmlForm->show();
226 226
 	}
227 227
 
@@ -231,18 +231,18 @@  discard block
 block discarded – undo
231 231
 	 * @return string HTML
232 232
 	 */
233 233
 	private function buildInfoBox() {
234
-		$externalDbLink = Linker::specialLink( 'ExternalDatabases', 'wbqev-externaldbs' );
234
+		$externalDbLink = Linker::specialLink('ExternalDatabases', 'wbqev-externaldbs');
235 235
 		$infoBox =
236 236
 			Html::openElement(
237 237
 				'div',
238
-				[ 'class' => 'wbqev-infobox' ]
238
+				['class' => 'wbqev-infobox']
239 239
 			)
240
-			. $this->msg( 'wbqev-crosscheck-explanation-general' )->parse()
241
-			. sprintf( ' %s.', $externalDbLink )
242
-			. Html::element( 'br' )
243
-			. Html::element( 'br' )
244
-			. $this->msg( 'wbqev-crosscheck-explanation-detail' )->parse()
245
-			. Html::closeElement( 'div' );
240
+			. $this->msg('wbqev-crosscheck-explanation-general')->parse()
241
+			. sprintf(' %s.', $externalDbLink)
242
+			. Html::element('br')
243
+			. Html::element('br')
244
+			. $this->msg('wbqev-crosscheck-explanation-detail')->parse()
245
+			. Html::closeElement('div');
246 246
 
247 247
 		return $infoBox;
248 248
 	}
@@ -257,16 +257,16 @@  discard block
 block discarded – undo
257 257
 	 *
258 258
 	 * @return string HTML
259 259
 	 */
260
-	private function buildNotice( $messageKey, $error = false ) {
260
+	private function buildNotice($messageKey, $error = false) {
261 261
 		$cssClasses = 'wbqev-crosscheck-notice';
262
-		if ( $error ) {
262
+		if ($error) {
263 263
 			$cssClasses .= ' wbqev-crosscheck-notice-error';
264 264
 		}
265 265
 
266 266
 		return Html::element(
267 267
 			'p',
268
-			[ 'class' => $cssClasses ],
269
-			$this->msg( $messageKey )->text()
268
+			['class' => $cssClasses],
269
+			$this->msg($messageKey)->text()
270 270
 		);
271 271
 	}
272 272
 
@@ -277,17 +277,17 @@  discard block
 block discarded – undo
277 277
 	 *
278 278
 	 * @return string HTML
279 279
 	 */
280
-	private function buildResultHeader( EntityId $entityId ) {
280
+	private function buildResultHeader(EntityId $entityId) {
281 281
 		$entityLink = sprintf(
282 282
 			'%s (%s)',
283
-			$this->entityIdLinkFormatter->formatEntityId( $entityId ),
284
-			htmlspecialchars( $entityId->getSerialization() )
283
+			$this->entityIdLinkFormatter->formatEntityId($entityId),
284
+			htmlspecialchars($entityId->getSerialization())
285 285
 		);
286 286
 
287 287
 		return Html::rawElement(
288 288
 			'h3',
289 289
 			[],
290
-			sprintf( '%s %s', $this->msg( 'wbqev-crosscheck-result-headline' )->escaped(), $entityLink )
290
+			sprintf('%s %s', $this->msg('wbqev-crosscheck-result-headline')->escaped(), $entityLink)
291 291
 		);
292 292
 	}
293 293
 
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
 	 *
299 299
 	 * @return string HTML
300 300
 	 */
301
-	private function buildSummary( $results ) {
301
+	private function buildSummary($results) {
302 302
 		$statuses = [];
303
-		foreach ( $results as $result ) {
304
-			$status = strtolower( $result->getComparisonResult()->getStatus() );
305
-			if ( array_key_exists( $status, $statuses ) ) {
303
+		foreach ($results as $result) {
304
+			$status = strtolower($result->getComparisonResult()->getStatus());
305
+			if (array_key_exists($status, $statuses)) {
306 306
 				$statuses[$status]++;
307 307
 			} else {
308 308
 				$statuses[$status] = 1;
@@ -310,15 +310,15 @@  discard block
 block discarded – undo
310 310
 		}
311 311
 
312 312
 		$statusElements = [];
313
-		foreach ( $statuses as $status => $count ) {
314
-			if ( $count > 0 ) {
315
-				$statusElements[] = $this->formatStatus( $status ) . ': ' . $count;
313
+		foreach ($statuses as $status => $count) {
314
+			if ($count > 0) {
315
+				$statusElements[] = $this->formatStatus($status).': '.$count;
316 316
 			}
317 317
 		}
318 318
 		$summary =
319
-			Html::openElement( 'p' )
320
-			. implode( ', ', $statusElements )
321
-			. Html::closeElement( 'p' );
319
+			Html::openElement('p')
320
+			. implode(', ', $statusElements)
321
+			. Html::closeElement('p');
322 322
 
323 323
 		return $summary;
324 324
 	}
@@ -332,16 +332,16 @@  discard block
 block discarded – undo
332 332
 	 *
333 333
 	 * @return string HTML
334 334
 	 */
335
-	private function formatStatus( $status ) {
336
-		$messageKey = 'wbqev-crosscheck-status-' . strtolower( $status );
335
+	private function formatStatus($status) {
336
+		$messageKey = 'wbqev-crosscheck-status-'.strtolower($status);
337 337
 
338 338
 		$formattedStatus =
339 339
 			Html::element(
340 340
 				'span',
341 341
 				[
342
-					'class' => 'wbqev-status wbqev-status-' . $status
342
+					'class' => 'wbqev-status wbqev-status-'.$status
343 343
 				],
344
-				$this->msg( $messageKey )->text()
344
+				$this->msg($messageKey)->text()
345 345
 			);
346 346
 
347 347
 		return $formattedStatus;
@@ -358,29 +358,29 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
 	 * @return string HTML
360 360
 	 */
361
-	private function formatDataValues( $dataValues, $linking = true, $separator = null ) {
362
-		if ( $dataValues instanceof DataValue ) {
363
-			$dataValues = [ $dataValues ];
361
+	private function formatDataValues($dataValues, $linking = true, $separator = null) {
362
+		if ($dataValues instanceof DataValue) {
363
+			$dataValues = [$dataValues];
364 364
 		}
365 365
 
366 366
 		$formattedDataValues = [];
367
-		foreach ( $dataValues as $dataValue ) {
368
-			if ( $dataValue instanceof EntityIdValue ) {
369
-				if ( $linking ) {
370
-					$formattedDataValues[] = $this->entityIdLinkFormatter->formatEntityId( $dataValue->getEntityId() );
367
+		foreach ($dataValues as $dataValue) {
368
+			if ($dataValue instanceof EntityIdValue) {
369
+				if ($linking) {
370
+					$formattedDataValues[] = $this->entityIdLinkFormatter->formatEntityId($dataValue->getEntityId());
371 371
 				} else {
372
-					$formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() );
372
+					$formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId());
373 373
 				}
374 374
 			} else {
375
-				$formattedDataValues[] = $this->dataValueFormatter->format( $dataValue );
375
+				$formattedDataValues[] = $this->dataValueFormatter->format($dataValue);
376 376
 			}
377 377
 		}
378 378
 
379
-		if ( $separator ) {
380
-			return implode( $separator, $formattedDataValues );
379
+		if ($separator) {
380
+			return implode($separator, $formattedDataValues);
381 381
 		}
382 382
 
383
-		return $this->getLanguage()->commaList( $formattedDataValues );
383
+		return $this->getLanguage()->commaList($formattedDataValues);
384 384
 	}
385 385
 
386 386
 	/**
@@ -388,31 +388,31 @@  discard block
 block discarded – undo
388 388
 	 *
389 389
 	 * @return string HTML
390 390
 	 */
391
-	private function buildResultTable( $results ) {
391
+	private function buildResultTable($results) {
392 392
 		$table = new HtmlTableBuilder(
393 393
 			[
394 394
 				new HtmlTableHeaderBuilder(
395
-					$this->msg( 'wbqev-crosscheck-result-table-header-status' )->escaped(),
395
+					$this->msg('wbqev-crosscheck-result-table-header-status')->escaped(),
396 396
 					true
397 397
 				),
398 398
 				new HtmlTableHeaderBuilder(
399
-					$this->msg( 'datatypes-type-wikibase-property' )->escaped(),
399
+					$this->msg('datatypes-type-wikibase-property')->escaped(),
400 400
 					true
401 401
 				),
402 402
 				new HtmlTableHeaderBuilder(
403
-					$this->msg( 'wbqev-crosscheck-result-table-header-local-value' )->escaped()
403
+					$this->msg('wbqev-crosscheck-result-table-header-local-value')->escaped()
404 404
 				),
405 405
 				new HtmlTableHeaderBuilder(
406
-					$this->msg( 'wbqev-crosscheck-result-table-header-external-value' )->escaped()
406
+					$this->msg('wbqev-crosscheck-result-table-header-external-value')->escaped()
407 407
 				),
408 408
 				new HtmlTableHeaderBuilder(
409
-					$this->msg( 'wbqev-crosscheck-result-table-header-references' )->escaped(),
409
+					$this->msg('wbqev-crosscheck-result-table-header-references')->escaped(),
410 410
 					true
411 411
 				),
412 412
 				new HtmlTableHeaderBuilder(
413 413
 					Linker::linkKnown(
414
-						self::getTitleFor( 'ExternalDatabases' ),
415
-						$this->msg( 'wbqev-crosscheck-result-table-header-external-source' )->escaped()
414
+						self::getTitleFor('ExternalDatabases'),
415
+						$this->msg('wbqev-crosscheck-result-table-header-external-source')->escaped()
416 416
 					),
417 417
 					true,
418 418
 					true
@@ -421,28 +421,28 @@  discard block
 block discarded – undo
421 421
 			true
422 422
 		);
423 423
 
424
-		foreach ( $results as $result ) {
425
-			$status = $this->formatStatus( $result->getComparisonResult()->getStatus() );
426
-			$propertyId = $this->entityIdLinkFormatter->formatEntityId( $result->getPropertyId() );
427
-			$localValue = $this->formatDataValues( $result->getComparisonResult()->getLocalValue() );
424
+		foreach ($results as $result) {
425
+			$status = $this->formatStatus($result->getComparisonResult()->getStatus());
426
+			$propertyId = $this->entityIdLinkFormatter->formatEntityId($result->getPropertyId());
427
+			$localValue = $this->formatDataValues($result->getComparisonResult()->getLocalValue());
428 428
 			$externalValue = $this->formatDataValues(
429 429
 				$result->getComparisonResult()->getExternalValues(),
430 430
 				true,
431
-				Html::element( 'br' )
431
+				Html::element('br')
432 432
 			);
433 433
 			$referenceStatus = $this->msg(
434
-				'wbqev-crosscheck-status-' . $result->getReferenceResult()->getStatus()
434
+				'wbqev-crosscheck-status-'.$result->getReferenceResult()->getStatus()
435 435
 			)->text();
436
-			$dataSource = $this->entityIdLinkFormatter->formatEntityId( $result->getDumpMetaInformation()->getSourceItemId() );
436
+			$dataSource = $this->entityIdLinkFormatter->formatEntityId($result->getDumpMetaInformation()->getSourceItemId());
437 437
 
438 438
 			$table->appendRow(
439 439
 				[
440
-					new HtmlTableCellBuilder( $status, [], true ),
441
-					new HtmlTableCellBuilder( $propertyId, [], true ),
442
-					new HtmlTableCellBuilder( $localValue, [], true ),
443
-					new HtmlTableCellBuilder( $externalValue, [], true ),
444
-					new HtmlTableCellBuilder( $referenceStatus, [] ),
445
-					new HtmlTableCellBuilder( $dataSource, [], true )
440
+					new HtmlTableCellBuilder($status, [], true),
441
+					new HtmlTableCellBuilder($propertyId, [], true),
442
+					new HtmlTableCellBuilder($localValue, [], true),
443
+					new HtmlTableCellBuilder($externalValue, [], true),
444
+					new HtmlTableCellBuilder($referenceStatus, []),
445
+					new HtmlTableCellBuilder($dataSource, [], true)
446 446
 				]
447 447
 			);
448 448
 		}
Please login to merge, or discard this patch.