Skip to content

Commit 107f243

Browse files
committed
CodePatcher docs
1 parent 2f5bf29 commit 107f243

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/CodePatcher.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
use PhpSchool\PhpWorkshop\Exercise\SubmissionPatcher;
1313

1414
/**
15-
* Class CodePatcher
15+
* Service to apply patches to a students solution. Accepts a default patch via the constructor.
16+
* Patched are pulled from the exercise (if it implements SubmissionPatchable) and applied to the
17+
* given code.
18+
*
1619
* @package PhpSchool\PhpWorkshop
1720
* @author Aydin Hassan <[email protected]>
1821
*/
@@ -34,6 +37,13 @@ class CodePatcher
3437
private $defaultPatch;
3538

3639
/**
40+
* This service requires an instance of Parser and Standard. These services allow
41+
* to parse code to an AST and to print code from an AST.
42+
*
43+
* The service also accepts a default patch. This allows a workshop to apply a patch
44+
* to every single student solution. This is used (by default) to modify various ini
45+
* settings, such as increasing the error reporting level.
46+
*
3747
* @param Parser $parser
3848
* @param Standard $printer
3949
* @param Patch $defaultPatch
@@ -46,6 +56,13 @@ public function __construct(Parser $parser, Standard $printer, Patch $defaultPat
4656
}
4757

4858
/**
59+
* Accepts an exercise and a string containing the students solution to the exercise.
60+
*
61+
* If there is a default patch, the students solution is patched with that.
62+
*
63+
* If the exercise implements SubmissionPatchable then the patch is pulled from it and applied to
64+
* the students solution.
65+
*
4966
* @param ExerciseInterface $exercise
5067
* @param string $code
5168
* @return string

0 commit comments

Comments
 (0)