Commit 7ce27f00 authored by Korko's avatar Korko Committed by StyleCI Bot
Browse files

Apply fixes from StyleCI

parent 408d0ab3
......@@ -5,8 +5,8 @@ namespace Korko\SecretSanta\Http\Controllers;
use Illuminate\Http\Request;
use Korko\SecretSanta\Http\Requests\RandomFormRequest;
use Mail;
use Solver;
use Sms;
use Solver;
use Statsd;
class RandomFormController extends Controller
......
......@@ -13,9 +13,10 @@ class HatSolver
shuffle($hat);
$generator = $this->getGenerator($participants, $exclusions, $hat);
if(!$generator->valid()) {
if (!$generator->valid()) {
throw new Exception('Cannot solve');
}
return $generator->current();
}
......@@ -24,7 +25,7 @@ class HatSolver
$combinations = [];
$generator = $this->getGenerator($participants, $exclusions, array_keys($participants));
foreach($generator as $combination) {
foreach ($generator as $combination) {
$combinations[] = $combination;
}
......@@ -41,12 +42,12 @@ class HatSolver
$actualExclusions = array_key_exists($i, $exclusions) ? $exclusions[$i] : [];
$actualHat = array_diff($hat, $actualExclusions, [$i]);
if($actualHat !== []) {
foreach($actualHat as $possibility) {
if ($actualHat !== []) {
foreach ($actualHat as $possibility) {
$possibilityCombination = $combination + [$i => $possibility];
$possibilityHat = array_diff($hat, [$possibility]);
if($possibilityHat === []) {
if ($possibilityHat === []) {
yield $possibilityCombination;
} else {
yield from $this->_solve($i + 1, $possibilityCombination, $exclusions, $possibilityHat);
......
<?php
return [
'sent' => 'Envoyé avec succès !'
'sent' => 'Envoyé avec succès !',
];
......@@ -8,6 +8,7 @@ class SolverTest extends TestCase
array_walk($el, function (&$idx) use ($participants) {
$idx = $participants[$idx];
});
return implode('', $el);
}, $test);
$this->assertEquals(sort($valid), sort($test));
......@@ -63,6 +64,7 @@ class SolverTest extends TestCase
$rand2 = rand(0, 10);
if ($rand1 !== $rand2) {
$this->markTestSkipped('srand disabled');
return;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment