88use ReflectionClass ;
99
1010/**
11- * Class AbstractExercise
11+ * This abstract class implements many of the methods described in `\PhpSchool\PhpWorkshop\Exercise\ExerciseInterface`.
12+ * It serves as a good base for an exercise, providing useful defaults for many of the methods.
13+ *
1214 * @package PhpSchool\PhpWorkshop\Exercise
1315 * @author Aydin Hassan <aydin@hotmail.co.uk>
1416 */
1517abstract class AbstractExercise
1618{
1719
1820 /**
21+ * Get the name of the exercise, like `Hello World!`.
22+ *
1923 * @return string
2024 */
2125 abstract public function getName ();
2226
2327 /**
28+ * This returns a single file solution named `solution.php` which
29+ * should exist in `workshop-root/exercises/<exercise-name>/solution/`.
30+ *
31+ * This method can be overwritten if the solution consists of multiple files,
32+ * see [Directory Solution](https://www.phpschool.io/docs/reference/exercise-solutions#directory-solution) for more details.
33+ *
2434 * @return SolutionInterface
2535 */
2636 public function getSolution ()
@@ -37,6 +47,9 @@ public function getSolution()
3747 }
3848
3949 /**
50+ * This returns the problem file path, which is assumed to exist in
51+ * `workshop-root/exercises/<exercise-name>/problem/` as a file named `problem.md`.
52+ *
4053 * @return string
4154 */
4255 public function getProblem ()
@@ -47,7 +60,10 @@ public function getProblem()
4760 }
4861
4962 /**
50- * @return null
63+ * Allows to perform some cleanup after the exercise solution's have been executed, for example
64+ * remove files, close DB connections.
65+ *
66+ * @return void
5167 */
5268 public function tearDown ()
5369 {
@@ -63,6 +79,9 @@ private function normaliseName($name)
6379 }
6480
6581 /**
82+ * This method is implemented as empty by default, if you want to add additional checks or listen
83+ * to events, you should override this method.
84+ *
6685 * @param ExerciseDispatcher $dispatcher
6786 */
6887 public function configure (ExerciseDispatcher $ dispatcher )
0 commit comments