Completed
Push — master ( 68eef5...7fee1f )
by Josh
01:38
created
src/ShortestCommonSuperstring.php 1 patch
Indentation   +41 added lines, -41 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,11 +73,11 @@  discard block
 block discarded – undo
73 73
 	}
74 74
 
75 75
 	/**
76
-	* Match and merge a string by key
77
-	*
78
-	* @param  integer $leftKey Left string's key
79
-	* @return bool             Whether a match was found and strings merged
80
-	*/
76
+	 * Match and merge a string by key
77
+	 *
78
+	 * @param  integer $leftKey Left string's key
79
+	 * @return bool             Whether a match was found and strings merged
80
+	 */
81 81
 	protected function mergeString(int $leftKey): bool
82 82
 	{
83 83
 		// Temporarily blank this string's prefix from the array to avoid matches
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 	}
100 100
 
101 101
 	/**
102
-	* Merge two stored strings together at current affix length
103
-	*/
102
+	 * Merge two stored strings together at current affix length
103
+	 */
104 104
 	protected function mergeStringPair(int $leftKey, int $rightKey): void
105 105
 	{
106 106
 		$this->strings[$leftKey] .= substr($this->strings[$rightKey], $this->len);
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	}
110 110
 
111 111
 	/**
112
-	* Merge all stored strings using current affix length
113
-	*/
112
+	 * Merge all stored strings using current affix length
113
+	 */
114 114
 	protected function mergeStrings(): void
115 115
 	{
116 116
 		$this->storeAffixes();
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 	}
128 128
 
129 129
 	/**
130
-	* Match and merge strings from given group
131
-	*
132
-	* @param  integer[] $keys List of keys
133
-	* @return void
134
-	*/
130
+	 * Match and merge strings from given group
131
+	 *
132
+	 * @param  integer[] $keys List of keys
133
+	 * @return void
134
+	 */
135 135
 	protected function mergeStringsGroup(array $keys): void
136 136
 	{
137 137
 		foreach ($keys as $leftKey)
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 	}
148 148
 
149 149
 	/**
150
-	* Remove empty strings from the list
151
-	*/
150
+	 * Remove empty strings from the list
151
+	 */
152 152
 	protected function removeEmptyStrings(): void
153 153
 	{
154 154
 		if (end($this->strings) === '')
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	}
159 159
 
160 160
 	/**
161
-	* Remove fully-overlapping strings from the list
162
-	*/
161
+	 * Remove fully-overlapping strings from the list
162
+	 */
163 163
 	protected function removeFullyOverlappingStrings(): void
164 164
 	{
165 165
 		// Copy the list of strings ordered by ascending length and create a master string by
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	}
193 193
 
194 194
 	/**
195
-	* Reset the keys in the string list to remove the gaps
196
-	*/
195
+	 * Reset the keys in the string list to remove the gaps
196
+	 */
197 197
 	protected function resetKeys(): void
198 198
 	{
199 199
 		end($this->strings);
@@ -204,18 +204,18 @@  discard block
 block discarded – undo
204 204
 	}
205 205
 
206 206
 	/**
207
-	* Sort the stored strings
208
-	*/
207
+	 * Sort the stored strings
208
+	 */
209 209
 	protected function sortStrings(): void
210 210
 	{
211 211
 		usort($this->strings, [__CLASS__, 'compareStrings']);
212 212
 	}
213 213
 
214 214
 	/**
215
-	* Capture and stored affixes of current length
216
-	*
217
-	* Will only store affixes from strings that are longer than current affix length
218
-	*/
215
+	 * Capture and stored affixes of current length
216
+	 *
217
+	 * Will only store affixes from strings that are longer than current affix length
218
+	 */
219 219
 	protected function storeAffixes(): void
220 220
 	{
221 221
 		$this->prefixes = [];
Please login to merge, or discard this patch.