Completed
Push — master ( aa17aa...00c4f5 )
by Josh
02:08
created
src/ShortestCommonSuperstring.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -10,31 +10,31 @@  discard block
 block discarded – undo
10 10
 class ShortestCommonSuperstring
11 11
 {
12 12
 	/**
13
-	* @var integer Affix length for current iteration
14
-	*/
13
+	 * @var integer Affix length for current iteration
14
+	 */
15 15
 	protected $len;
16 16
 
17 17
 	/**
18
-	* @var string[] Prefixes of current length
19
-	*/
18
+	 * @var string[] Prefixes of current length
19
+	 */
20 20
 	protected $prefixes;
21 21
 
22 22
 	/**
23
-	* @var string[] Strings being merged
24
-	*/
23
+	 * @var string[] Strings being merged
24
+	 */
25 25
 	protected $strings;
26 26
 
27 27
 	/**
28
-	* @var string[] Suffixes of current length
29
-	*/
28
+	 * @var string[] Suffixes of current length
29
+	 */
30 30
 	protected $suffixes;
31 31
 
32 32
 	/**
33
-	* Get the shortest string that contains all given strings
34
-	*
35
-	* @param  string[] $strings
36
-	* @return string
37
-	*/
33
+	 * Get the shortest string that contains all given strings
34
+	 *
35
+	 * @param  string[] $strings
36
+	 * @return string
37
+	 */
38 38
 	public function getShortest(array $strings): string
39 39
 	{
40 40
 		$this->strings = array_unique($strings);
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 	/**
57
-	* Compare given strings
58
-	*/
57
+	 * Compare given strings
58
+	 */
59 59
 	protected static function compareStrings(string $a, string $b): int
60 60
 	{
61 61
 		$aLen = strlen($a);
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 	}
72 72
 
73 73
 	/**
74
-	* Return the list of keys pointing to strings whose prefix is identical to their suffix
75
-	*
76
-	* @return integer[]
77
-	*/
74
+	 * Return the list of keys pointing to strings whose prefix is identical to their suffix
75
+	 *
76
+	 * @return integer[]
77
+	 */
78 78
 	protected function getIdenticalAffixKeys(): array
79 79
 	{
80 80
 		$identicalAffixKeys = [];
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 	}
91 91
 
92 92
 	/**
93
-	* Match and merge a string by key
94
-	*
95
-	* @param  integer $leftKey Left string's key
96
-	* @return bool             Whether a match was found and strings merged
97
-	*/
93
+	 * Match and merge a string by key
94
+	 *
95
+	 * @param  integer $leftKey Left string's key
96
+	 * @return bool             Whether a match was found and strings merged
97
+	 */
98 98
 	protected function mergeString(int $leftKey): bool
99 99
 	{
100 100
 		$suffix = $this->suffixes[$leftKey];
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	}
113 113
 
114 114
 	/**
115
-	* Merge two stored strings together at current affix length
116
-	*/
115
+	 * Merge two stored strings together at current affix length
116
+	 */
117 117
 	protected function mergeStringPair(int $leftKey, int $rightKey): void
118 118
 	{
119 119
 		$this->strings[$leftKey] .= substr($this->strings[$rightKey], $this->len);
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	}
123 123
 
124 124
 	/**
125
-	* Merge all stored strings using current affix length
126
-	*/
125
+	 * Merge all stored strings using current affix length
126
+	 */
127 127
 	protected function mergeStrings(): void
128 128
 	{
129 129
 		$this->storeAffixes();
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
 	}
141 141
 
142 142
 	/**
143
-	* Match and merge strings from given group
144
-	*
145
-	* @param  integer[] $keys List of keys
146
-	* @return void
147
-	*/
143
+	 * Match and merge strings from given group
144
+	 *
145
+	 * @param  integer[] $keys List of keys
146
+	 * @return void
147
+	 */
148 148
 	protected function mergeStringsGroup(array $keys): void
149 149
 	{
150 150
 		foreach ($keys as $leftKey)
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	}
161 161
 
162 162
 	/**
163
-	* Remove empty strings from the list
164
-	*/
163
+	 * Remove empty strings from the list
164
+	 */
165 165
 	protected function removeEmptyStrings(): void
166 166
 	{
167 167
 		if (end($this->strings) === '')
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	}
172 172
 
173 173
 	/**
174
-	* Remove fully-overlapping strings from the list
175
-	*/
174
+	 * Remove fully-overlapping strings from the list
175
+	 */
176 176
 	protected function removeFullyOverlappingStrings(): void
177 177
 	{
178 178
 		$strlen = array_map('strlen', $this->strings);
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	}
200 200
 
201 201
 	/**
202
-	* Reset the keys in the string list to remove the gaps
203
-	*/
202
+	 * Reset the keys in the string list to remove the gaps
203
+	 */
204 204
 	protected function resetKeys(): void
205 205
 	{
206 206
 		end($this->strings);
@@ -211,18 +211,18 @@  discard block
 block discarded – undo
211 211
 	}
212 212
 
213 213
 	/**
214
-	* Sort the stored strings
215
-	*/
214
+	 * Sort the stored strings
215
+	 */
216 216
 	protected function sortStrings(): void
217 217
 	{
218 218
 		usort($this->strings, [__CLASS__, 'compareStrings']);
219 219
 	}
220 220
 
221 221
 	/**
222
-	* Capture and stored affixes of current length
223
-	*
224
-	* Will only store affixes from strings that are longer than current affix length
225
-	*/
222
+	 * Capture and stored affixes of current length
223
+	 *
224
+	 * Will only store affixes from strings that are longer than current affix length
225
+	 */
226 226
 	protected function storeAffixes(): void
227 227
 	{
228 228
 		$this->prefixes = [];
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare(strict_types = 1);
1
+<?php declare(strict_types=1);
2 2
 
3 3
 /**
4 4
 * @package   s9e\ShortestCommonSuperstring
Please login to merge, or discard this patch.