|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use function DI\factory; |
|
4
|
|
|
use function DI\object; |
|
5
|
|
|
use Interop\Container\ContainerInterface; |
|
6
|
|
|
use PhpParser\Parser; |
|
7
|
|
|
use PhpSchool\LearnYouPhp\Exercise\ArrayWeGo; |
|
8
|
|
|
use PhpSchool\LearnYouPhp\Exercise\BabySteps; |
|
9
|
|
|
use PhpSchool\LearnYouPhp\Exercise\ConcernedAboutSeparation; |
|
10
|
|
|
use PhpSchool\LearnYouPhp\Exercise\DatabaseRead; |
|
11
|
|
|
use PhpSchool\LearnYouPhp\Exercise\ExceptionalCoding; |
|
12
|
|
|
use PhpSchool\LearnYouPhp\Exercise\FilteredLs; |
|
13
|
|
|
use PhpSchool\LearnYouPhp\Exercise\HelloWorld; |
|
14
|
|
|
use PhpSchool\LearnYouPhp\Exercise\HttpJsonApi; |
|
15
|
|
|
use PhpSchool\LearnYouPhp\Exercise\MyFirstIo; |
|
16
|
|
|
use PhpSchool\LearnYouPhp\Exercise\TimeServer; |
|
17
|
|
|
use PhpSchool\LearnYouPhp\Exercise\DependencyHeaven; |
|
18
|
|
|
use PhpSchool\LearnYouPhp\TcpSocketFactory; |
|
19
|
|
|
use PhpSchool\PhpWorkshop\Event\Event; |
|
20
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
|
21
|
|
|
use Faker\Factory as FakerFactory; |
|
22
|
|
|
|
|
23
|
|
|
return [ |
|
24
|
|
|
//Exercises |
|
25
|
|
|
BabySteps::class => object(BabySteps::class), |
|
26
|
|
|
HelloWorld::class => object(HelloWorld::class), |
|
27
|
|
|
HttpJsonApi::class => object(HttpJsonApi::class), |
|
28
|
|
|
MyFirstIo::class => factory(function (ContainerInterface $c) { |
|
29
|
|
|
return new MyFirstIo($c->get(Filesystem::class), FakerFactory::create()); |
|
30
|
|
|
}), |
|
31
|
|
|
FilteredLs::class => factory(function (ContainerInterface $c) { |
|
32
|
|
|
return new FilteredLs($c->get(Filesystem::class)); |
|
33
|
|
|
}), |
|
34
|
|
|
ConcernedAboutSeparation::class => factory(function (ContainerInterface $c) { |
|
35
|
|
|
return new ConcernedAboutSeparation( |
|
36
|
|
|
$c->get(Filesystem::class), |
|
37
|
|
|
FakerFactory::create(), |
|
38
|
|
|
$c->get(Parser::class) |
|
39
|
|
|
); |
|
40
|
|
|
}), |
|
41
|
|
|
ArrayWeGo::class => factory(function (ContainerInterface $c) { |
|
42
|
|
|
return new ArrayWeGo($c->get(Filesystem::class), FakerFactory::create()); |
|
43
|
|
|
}), |
|
44
|
|
|
ExceptionalCoding::class => factory(function (ContainerInterface $c) { |
|
45
|
|
|
return new ExceptionalCoding($c->get(Filesystem::class), FakerFactory::create()); |
|
46
|
|
|
}), |
|
47
|
|
|
DatabaseRead::class => factory(function (ContainerInterface $c) { |
|
48
|
|
|
return new DatabaseRead(FakerFactory::create()); |
|
49
|
|
|
}), |
|
50
|
|
|
TimeServer::class => factory(function (ContainerInterface $c) { |
|
|
|
|
|
|
51
|
|
|
return new TimeServer(new TcpSocketFactory); |
|
52
|
|
|
}), |
|
53
|
|
|
DependencyHeaven::class => factory(function (ContainerInterface $c) { |
|
54
|
|
|
return new DependencyHeaven(FakerFactory::create('fr_FR')); |
|
55
|
|
|
}), |
|
56
|
|
|
|
|
57
|
|
|
'eventListeners' => [ |
|
58
|
|
|
'create-solution-for-first-exercise' => [ |
|
59
|
|
|
'exercise.selected.hello-world' => [ |
|
60
|
|
|
function () { |
|
61
|
|
|
if (!file_exists('hello-world.php')) { |
|
62
|
|
|
touch('hello-world.php'); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
] |
|
66
|
|
|
] |
|
67
|
|
|
] |
|
68
|
|
|
]; |
|
69
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.