1 | <?php |
||
19 | class FilteredLs extends AbstractExercise implements ExerciseInterface, CliExercise |
||
20 | { |
||
21 | use TemporaryDirectoryTrait; |
||
22 | |||
23 | /** |
||
24 | * @var Filesystem |
||
25 | */ |
||
26 | private $filesystem; |
||
27 | |||
28 | /** |
||
29 | * @param Filesystem $filesystem |
||
30 | */ |
||
31 | public function __construct(Filesystem $filesystem) |
||
35 | |||
36 | /** |
||
37 | * @return string |
||
38 | */ |
||
39 | public function getName() |
||
43 | |||
44 | /** |
||
45 | * @return string |
||
46 | */ |
||
47 | public function getDescription() |
||
51 | |||
52 | /** |
||
53 | * @return array |
||
54 | */ |
||
55 | public function getArgs() |
||
56 | { |
||
57 | $folder = $this->getTemporaryPath(); |
||
58 | |||
59 | $files = [ |
||
60 | "learnyouphp.dat", |
||
61 | "learnyouphp.txt", |
||
62 | "learnyouphp.sql", |
||
63 | "txt", |
||
64 | "sql", |
||
65 | "api.html", |
||
66 | "html", |
||
67 | "README.md", |
||
68 | "CHANGELOG.md", |
||
69 | "LICENCE.md", |
||
70 | "md", |
||
71 | "data.json", |
||
72 | "json", |
||
73 | "data.dat", |
||
74 | "words.dat", |
||
75 | "w00t.dat", |
||
76 | "w00t.txt", |
||
77 | "wrrrrongdat", |
||
78 | "dat", |
||
79 | ]; |
||
80 | |||
81 | $this->filesystem->mkdir($folder); |
||
82 | array_walk($files, function ($file) use ($folder) { |
||
83 | $this->filesystem->dumpFile(sprintf('%s/%s', $folder, $file), ''); |
||
84 | }); |
||
85 | |||
86 | $ext = ''; |
||
87 | while ($ext === '') { |
||
88 | $index = array_rand($files); |
||
89 | $ext = pathinfo($files[$index], PATHINFO_EXTENSION); |
||
90 | } |
||
91 | |||
92 | return [$folder, $ext]; |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @return null |
||
97 | */ |
||
98 | public function tearDown() |
||
102 | |||
103 | /** |
||
104 | * @return ExerciseType |
||
105 | */ |
||
106 | public function getType() |
||
110 | } |
||
111 |