-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchupi.php
27 lines (20 loc) · 894 Bytes
/
chupi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php require 'vendor/autoload.php';
use Colors\Color;
use LaSalle\ChupiProject\Module\Color\Domain\RandomColorSearcher;
use LaSalle\ChupiProject\Module\Color\Infrastructure\InMemoryColorRepository;
use LaSalle\ChupiProject\Module\CoolWord\Domain\RandomCoolWordSearcher;
use LaSalle\ChupiProject\Module\CoolWord\Infrastructure\InMemoryCoolWordRepository;
$wordSearcher = new RandomCoolWordSearcher(new InMemoryCoolWordRepository());
$colorSearcher = new RandomColorSearcher(new InMemoryColorRepository());
$bgColor = $colorSearcher();
$fgColor = _random_color_except($bgColor, $colorSearcher);
$c = new Color();
echo $c($wordSearcher())->bg($bgColor)->$fgColor . PHP_EOL;
function _random_color_except(string $except, callable $randomColorSearcher): string
{
$return = $except;
while ($except === $return) {
$return = $randomColorSearcher();
}
return $return;
}