Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Korko
SecretSanta.fr
Commits
7ce27f00
Commit
7ce27f00
authored
Dec 21, 2016
by
Korko
Committed by
StyleCI Bot
Dec 21, 2016
Browse files
Apply fixes from StyleCI
parent
408d0ab3
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/RandomFormController.php
View file @
7ce27f00
...
...
@@ -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
...
...
app/Libs/HatSolver.php
View file @
7ce27f00
...
...
@@ -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
);
...
...
resources/lang/fr/message.php
View file @
7ce27f00
<?php
return
[
'sent'
=>
'Envoyé avec succès !'
'sent'
=>
'Envoyé avec succès !'
,
];
tests/SolverTest.php
View file @
7ce27f00
...
...
@@ -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
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment