Passed
Push — master ( c8578e...f5141b )
by Sam
01:10 queued 12s
created
src/CharacterMaps/Maori.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
 
60 60
     public function unmapChars($word)
61 61
     {
62
-        $keys = collect($this->mappedChars)->mapWithKeys(function ($val, $key) {
62
+        $keys = collect($this->mappedChars)->mapWithKeys(function($val, $key) {
63 63
             return [Str::upper($key) => Str::upper($val)];
64 64
         })->toArray();
65 65
 
Please login to merge, or discard this patch.
src/Traits/HasWordCollection.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
     {
22 22
         $this->wordsCollection = $wordsCollection
23 23
             ->map(
24
-                function ($word) {
24
+                function($word) {
25 25
                     $charClass = resolve(config('word-finder.character_map'));
26 26
                     $word = (method_exists($charClass, 'mapChars')) ? $charClass->mapChars($word) : $word;
27 27
                     return Str::replace(" ", "", Str::upper($word));
28 28
                 }
29 29
             )
30 30
             ->filter(
31
-                fn ($word) =>  Str::length($word) >= $this->minWordLen && Str::length($word) <= $this->maxWordLen
31
+                fn($word) =>  Str::length($word) >= $this->minWordLen && Str::length($word) <= $this->maxWordLen
32 32
             );
33 33
 
34 34
         $this->wordLengths = $this->wordsCollection->mapToGroups(fn($word) => [Str::length($word) => $word]);
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             $len = $this->wordLengths->keys()->random();
48 48
         } while (in_array($len, $exclude));
49 49
 
50
-        $available = $this->wordsCollection->filter(fn ($word) => Str::length($word) === $len)->count();
50
+        $available = $this->wordsCollection->filter(fn($word) => Str::length($word) === $len)->count();
51 51
 
52 52
         if ($available > 0) {
53 53
             return $len;
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 
61 61
     protected function markWordUsed($word): void
62 62
     {
63
-        $this->wordsCollection = $this->wordsCollection->reject(function ($current) use ($word) {
63
+        $this->wordsCollection = $this->wordsCollection->reject(function($current) use ($word) {
64 64
             return $current === $word;
65 65
         });
66 66
     }
67 67
 
68 68
     protected function getRandomWord(int $len): string
69 69
     {
70
-        $word = $this->wordsCollection->filter(function ($word) use ($len) {
70
+        $word = $this->wordsCollection->filter(function($word) use ($len) {
71 71
             return Str::length($word) === $len;
72 72
         })->random(1)->first();
73 73
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     protected function getWordLike(string $pattern): ?string
80 80
     {
81 81
         $pattern = Str::replace("_", ".", $pattern);
82
-        $words = $this->wordsCollection->filter(function ($word) use ($pattern) {
82
+        $words = $this->wordsCollection->filter(function($word) use ($pattern) {
83 83
             return preg_match("/^$pattern\$/i", $word);
84 84
         });
85 85
 
Please login to merge, or discard this patch.
src/Grid.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -290,7 +290,7 @@
 block discarded – undo
290 290
     {
291 291
         return collect($this->wordsList)->map(function (Word $word) {
292 292
             $str = $word->getLabel(true);
293
-             $charClass = resolve(config('word-finder.character_map'));
293
+                $charClass = resolve(config('word-finder.character_map'));
294 294
 
295 295
             return method_exists($charClass, 'unmapChars') ? $charClass->unmapChars($str) : $str;
296 296
         });
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $this->cells = array_fill(0, $this->gridSize * $this->gridSize, null);
74 74
 
75 75
         for ($i = 0; $i < (2 * $this->gridSize * $this->gridSize); $i++) {
76
-            $this->columnArray[$i]=$this->getColumnDefault($i);
76
+            $this->columnArray[$i] = $this->getColumnDefault($i);
77 77
         }
78 78
 
79 79
         return $this;
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
     public function generate(): self
83 83
     {
84 84
         $blocks = $this->gridSize * $this->gridSize; //36
85
-        $i=rand(0, $blocks-1);
85
+        $i = rand(0, $blocks - 1);
86 86
 
87
-        $complete=0;                   //0
87
+        $complete = 0; //0
88 88
         while ($complete < $blocks) {
89 89
             $this->placeWord($i);
90 90
             $complete++;
91 91
             $i++;
92
-            if ($i==$blocks) {
93
-                $i=0;
92
+            if ($i == $blocks) {
93
+                $i = 0;
94 94
             }
95 95
         }
96 96
 
@@ -100,25 +100,25 @@  discard block
 block discarded – undo
100 100
     protected function addPlacedWord(Word $word, int $increment, int $len): void
101 101
     {
102 102
         $string = '';
103
-        $flag=false;
103
+        $flag = false;
104 104
 
105
-        for ($i=$word->getStart(); $i<=$word->getEnd(); $i+=$increment) {
105
+        for ($i = $word->getStart(); $i <= $word->getEnd(); $i += $increment) {
106 106
             if ($this->cells[$i] === null) {
107 107
                 $string .= '_';
108 108
             } else {
109 109
                 $string .= $this->cells[$i];
110
-                $flag=true;
110
+                $flag = true;
111 111
             }
112 112
         }
113 113
 
114
-        if (! $flag) {
114
+        if (!$flag) {
115 115
             $randomWord = $this->getRandomWord($len);
116 116
             $word->setLabel($randomWord);
117 117
             $this->addWord($word);
118 118
             return;
119 119
         }
120 120
 
121
-        if (Str::contains($string, '_')===false) {
121
+        if (Str::contains($string, '_') === false) {
122 122
             return;
123 123
         }
124 124
 
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
     protected function placeWordHorizontally(Word $word, int $len): void
130 130
     {
131 131
         $inc = 1;
132
-        $word->setEnd($word->getStart()+$len-1);
132
+        $word->setEnd($word->getStart() + $len - 1);
133 133
         while ($this->columnArray[$word->getEnd()] < $this->columnArray[$word->getStart()]) {
134
-            $word->setStart($word->getStart()-1);
135
-            $word->setEnd($word->getStart()+$len-1);
134
+            $word->setStart($word->getStart() - 1);
135
+            $word->setEnd($word->getStart() + $len - 1);
136 136
         }
137 137
 
138 138
         $this->addPlacedWord($word, $inc, $len);
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
 
141 141
     protected function placeWordVertical(Word $word, int $len): void
142 142
     {
143
-        $inc=$this->gridSize;
144
-        $word->setEnd($word->getStart()+($len*$this->gridSize)-$this->gridSize);
145
-        while ($word->getEnd()>($this->gridSize*$this->gridSize)-1) {
146
-            $word->setStart($word->getStart()-$this->gridSize);
147
-            $word->setEnd($word->getStart()+($len*$this->gridSize)-$this->gridSize);
143
+        $inc = $this->gridSize;
144
+        $word->setEnd($word->getStart() + ($len * $this->gridSize) - $this->gridSize);
145
+        while ($word->getEnd() > ($this->gridSize * $this->gridSize) - 1) {
146
+            $word->setStart($word->getStart() - $this->gridSize);
147
+            $word->setEnd($word->getStart() + ($len * $this->gridSize) - $this->gridSize);
148 148
         }
149 149
 
150 150
         $this->addPlacedWord($word, $inc, $len);
@@ -152,30 +152,30 @@  discard block
 block discarded – undo
152 152
 
153 153
     protected function placeWordDiagonallyLtr(Word $word, int $len): void
154 154
     {
155
-        $inc=$this->gridSize+1;
156
-        $word->setEnd($word->getStart()+($len*($this->gridSize+1))-($this->gridSize+1));
155
+        $inc = $this->gridSize + 1;
156
+        $word->setEnd($word->getStart() + ($len * ($this->gridSize + 1)) - ($this->gridSize + 1));
157 157
         while ($this->columnArray[$word->getEnd()] < $this->columnArray[$word->getStart()]) {
158
-            $word->setStart($word->getStart()-1);
159
-            $word->setEnd($word->getStart()+($len*($this->gridSize+1))-($this->gridSize+1));
158
+            $word->setStart($word->getStart() - 1);
159
+            $word->setEnd($word->getStart() + ($len * ($this->gridSize + 1)) - ($this->gridSize + 1));
160 160
         }
161
-        while ($word->getEnd()>($this->gridSize*$this->gridSize)-1) {
162
-            $word->setStart($word->getStart()-$this->gridSize);
163
-            $word->setEnd($word->getStart()+($len*($this->gridSize+1))-($this->gridSize+1));
161
+        while ($word->getEnd() > ($this->gridSize * $this->gridSize) - 1) {
162
+            $word->setStart($word->getStart() - $this->gridSize);
163
+            $word->setEnd($word->getStart() + ($len * ($this->gridSize + 1)) - ($this->gridSize + 1));
164 164
         }
165 165
         $this->addPlacedWord($word, $inc, $len);
166 166
     }
167 167
 
168 168
     protected function placeWordDiagonallyRtl(Word $word, int $len): void
169 169
     {
170
-        $inc=$this->gridSize-1;
171
-        $word->setEnd($word->getStart()+(($len-1)*($this->gridSize-1)));
170
+        $inc = $this->gridSize - 1;
171
+        $word->setEnd($word->getStart() + (($len - 1) * ($this->gridSize - 1)));
172 172
         while ($this->columnArray[$word->getEnd()] > $this->columnArray[$word->getStart()]) {
173
-            $word->setStart($word->getStart()+1);
174
-            $word->setEnd($word->getStart()+(($len-1)*($this->gridSize-1)));
173
+            $word->setStart($word->getStart() + 1);
174
+            $word->setEnd($word->getStart() + (($len - 1) * ($this->gridSize - 1)));
175 175
         }
176
-        while ($word->getEnd()>($this->gridSize*$this->gridSize)-1) {
177
-            $word->setStart($word->getStart()-$this->gridSize);
178
-            $word->setEnd($word->getStart()+(($len-1)*($this->gridSize-1)));
176
+        while ($word->getEnd() > ($this->gridSize * $this->gridSize) - 1) {
177
+            $word->setStart($word->getStart() - $this->gridSize);
178
+            $word->setEnd($word->getStart() + (($len - 1) * ($this->gridSize - 1)));
179 179
         }
180 180
         $this->addPlacedWord($word, $inc, $len);
181 181
     }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 
210 210
     protected function getColumnDefault(int $x): int
211 211
     {
212
-        return ($x % $this->gridSize)+1;
212
+        return ($x % $this->gridSize) + 1;
213 213
     }
214 214
 
215 215
     protected function addWord(Word $word): void
@@ -218,37 +218,37 @@  discard block
 block discarded – undo
218 218
             return;
219 219
         }
220 220
 
221
-        $j=0;
221
+        $j = 0;
222 222
         $incrementBy = 1;
223 223
         switch ($word->getOrientation()) {
224 224
             case Word::HORIZONTAL:
225
-                $incrementBy=1;
225
+                $incrementBy = 1;
226 226
                 break;
227 227
 
228 228
             case Word::VERTICAL:
229
-                $incrementBy=$this->gridSize;
229
+                $incrementBy = $this->gridSize;
230 230
                 break;
231 231
 
232 232
             case Word::DIAGONAL_LEFT_TO_RIGHT:
233
-                $incrementBy=$this->gridSize+1;
233
+                $incrementBy = $this->gridSize + 1;
234 234
                 break;
235 235
 
236 236
             case Word::DIAGONAL_RIGHT_TO_LEFT:
237
-                $incrementBy=$this->gridSize-1;
237
+                $incrementBy = $this->gridSize - 1;
238 238
                 break;
239 239
         }
240 240
 
241 241
         for ($i = $word->getStart(); $j < Str::length($word->getLabel()); $i += $incrementBy) {
242 242
             $nchar = Str::substr($word->getLabel(), $j, 1);
243 243
             if ($this->cells[$i] !== $nchar
244
-                && ! is_null($this->cells[$i])) {
244
+                && !is_null($this->cells[$i])) {
245 245
                 throw new RuntimeException("Null or Char required: {$this->cells[$i]} - {$nchar}");
246 246
             }
247 247
             $this->cells[$i] = Str::substr($word->getLabel(), $j, 1);
248 248
             $j++;
249 249
         }
250 250
 
251
-        $this->wordsList[]=$word;
251
+        $this->wordsList[] = $word;
252 252
     }
253 253
 
254 254
     public function getTextGrid()
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 
289 289
     public function getPuzzleWords()
290 290
     {
291
-        return collect($this->wordsList)->map(function (Word $word) {
291
+        return collect($this->wordsList)->map(function(Word $word) {
292 292
             $str = $word->getLabel(true);
293 293
              $charClass = resolve(config('word-finder.character_map'));
294 294
 
Please login to merge, or discard this patch.