Completed
Push — master ( 197572...68eef5 )
by Josh
15:49 queued 14:34
created
src/ShortestCommonSuperstring.php 1 patch
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);
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	}
57 57
 
58 58
 	/**
59
-	* Compare given strings
60
-	*/
59
+	 * Compare given strings
60
+	 */
61 61
 	protected static function compareStrings(string $a, string $b): int
62 62
 	{
63 63
 		$aLen = strlen($a);
@@ -73,21 +73,21 @@  discard block
 block discarded – undo
73 73
 	}
74 74
 
75 75
 	/**
76
-	* Return the list of keys pointing to strings whose prefix is identical to their suffix
77
-	*
78
-	* @return integer[]
79
-	*/
76
+	 * Return the list of keys pointing to strings whose prefix is identical to their suffix
77
+	 *
78
+	 * @return integer[]
79
+	 */
80 80
 	protected function getIdenticalAffixKeys(): array
81 81
 	{
82 82
 		return array_keys(array_intersect_assoc($this->prefixes, $this->suffixes));
83 83
 	}
84 84
 
85 85
 	/**
86
-	* Match and merge a string by key
87
-	*
88
-	* @param  integer $leftKey Left string's key
89
-	* @return bool             Whether a match was found and strings merged
90
-	*/
86
+	 * Match and merge a string by key
87
+	 *
88
+	 * @param  integer $leftKey Left string's key
89
+	 * @return bool             Whether a match was found and strings merged
90
+	 */
91 91
 	protected function mergeString(int $leftKey): bool
92 92
 	{
93 93
 		// Temporarily blank this string's prefix from the array to avoid matches
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	}
110 110
 
111 111
 	/**
112
-	* Merge two stored strings together at current affix length
113
-	*/
112
+	 * Merge two stored strings together at current affix length
113
+	 */
114 114
 	protected function mergeStringPair(int $leftKey, int $rightKey): void
115 115
 	{
116 116
 		$this->strings[$leftKey] .= substr($this->strings[$rightKey], $this->len);
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	}
120 120
 
121 121
 	/**
122
-	* Merge all stored strings using current affix length
123
-	*/
122
+	 * Merge all stored strings using current affix length
123
+	 */
124 124
 	protected function mergeStrings(): void
125 125
 	{
126 126
 		$this->storeAffixes();
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 	}
138 138
 
139 139
 	/**
140
-	* Match and merge strings from given group
141
-	*
142
-	* @param  integer[] $keys List of keys
143
-	* @return void
144
-	*/
140
+	 * Match and merge strings from given group
141
+	 *
142
+	 * @param  integer[] $keys List of keys
143
+	 * @return void
144
+	 */
145 145
 	protected function mergeStringsGroup(array $keys): void
146 146
 	{
147 147
 		foreach ($keys as $leftKey)
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	}
158 158
 
159 159
 	/**
160
-	* Remove empty strings from the list
161
-	*/
160
+	 * Remove empty strings from the list
161
+	 */
162 162
 	protected function removeEmptyStrings(): void
163 163
 	{
164 164
 		if (end($this->strings) === '')
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	}
169 169
 
170 170
 	/**
171
-	* Remove fully-overlapping strings from the list
172
-	*/
171
+	 * Remove fully-overlapping strings from the list
172
+	 */
173 173
 	protected function removeFullyOverlappingStrings(): void
174 174
 	{
175 175
 		// Copy the list of strings ordered by ascending length and create a master string by
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 	}
203 203
 
204 204
 	/**
205
-	* Reset the keys in the string list to remove the gaps
206
-	*/
205
+	 * Reset the keys in the string list to remove the gaps
206
+	 */
207 207
 	protected function resetKeys(): void
208 208
 	{
209 209
 		end($this->strings);
@@ -214,18 +214,18 @@  discard block
 block discarded – undo
214 214
 	}
215 215
 
216 216
 	/**
217
-	* Sort the stored strings
218
-	*/
217
+	 * Sort the stored strings
218
+	 */
219 219
 	protected function sortStrings(): void
220 220
 	{
221 221
 		usort($this->strings, [__CLASS__, 'compareStrings']);
222 222
 	}
223 223
 
224 224
 	/**
225
-	* Capture and stored affixes of current length
226
-	*
227
-	* Will only store affixes from strings that are longer than current affix length
228
-	*/
225
+	 * Capture and stored affixes of current length
226
+	 *
227
+	 * Will only store affixes from strings that are longer than current affix length
228
+	 */
229 229
 	protected function storeAffixes(): void
230 230
 	{
231 231
 		$this->prefixes = [];
Please login to merge, or discard this patch.