77use PhpSchool \PhpWorkshop \Exception \CodeExecutionException ;
88
99/**
10- * Class Failure
10+ * Default implementation of `PhpSchool\PhpWorkshop\Result\FailureInterface`.
11+ *
1112 * @package PhpSchool\PhpWorkshop
1213 * @author Aydin Hassan <aydin@hotmail.co.uk>
1314 */
@@ -24,8 +25,11 @@ class Failure implements FailureInterface
2425 private $ name ;
2526
2627 /**
27- * @param string $name
28- * @param string|null $reason
28+ * Create an instance from the name of the check that produces this result
29+ * and the reason for the failure.
30+ *
31+ * @param string $name The name of the check that produced this result.
32+ * @param string|null $reason The reason (if any) of the failure.
2933 */
3034 public function __construct ($ name , $ reason = null )
3135 {
@@ -34,40 +38,49 @@ public function __construct($name, $reason = null)
3438 }
3539
3640 /**
37- * @param string $name
38- * @param $reason
39- * @return static
41+ * Named constructor, for added code legibility.
42+ *
43+ * @param string $name The name of the check that produced this result.
44+ * @param string|null $reason The reason (if any) of the failure.
45+ * @return static The result.
4046 */
4147 public static function fromNameAndReason ($ name , $ reason )
4248 {
4349 return new static ($ name , $ reason );
4450 }
4551
4652 /**
47- * @param CheckInterface $check
48- * @param string $reason
49- * @return static
53+ * Static constructor to create from an instance of `PhpSchool\PhpWorkshop\Check\CheckInterface`.
54+ *
55+ * @param CheckInterface $check The check instance.
56+ * @param string $reason The reason (if any) of the failure.
57+ * @return static The result.
5058 */
5159 public static function fromCheckAndReason (CheckInterface $ check , $ reason )
5260 {
5361 return new static ($ check ->getName (), $ reason );
5462 }
5563
5664 /**
57- * @param string $name
58- * @param CodeExecutionException $e
59- * @return static
65+ * Static constructor to create from a `PhpSchool\PhpWorkshop\Exception\CodeExecutionException` exception.
66+ *
67+ * @param string $name The name of the check that produced this result.
68+ * @param CodeExecutionException $e The exception.
69+ * @return static The result.
6070 */
6171 public static function fromNameAndCodeExecutionFailure ($ name , CodeExecutionException $ e )
6272 {
6373 return new static ($ name , $ e ->getMessage ());
6474 }
6575
6676 /**
67- * @param CheckInterface $check
68- * @param ParseErrorException $e
69- * @param string $file
70- * @return static
77+ * Static constructor to create from a `PhpParser\Error` exception. Many checks will need to parse the student's
78+ * solution, so this serves as a helper to create a consistent failure.
79+ *
80+ * @param CheckInterface $check The check that attempted to parse the solution.
81+ * @param ParseErrorException $e The parse exception.
82+ * @param string $file The absolute path to the solution.
83+ * @return static The result.
7184 */
7285 public static function fromCheckAndCodeParseFailure (CheckInterface $ check , ParseErrorException $ e , $ file )
7386 {
@@ -78,6 +91,8 @@ public static function fromCheckAndCodeParseFailure(CheckInterface $check, Parse
7891 }
7992
8093 /**
94+ * Get the name of the check that this result was produced from.
95+ *
8196 * @return string
8297 */
8398 public function getCheckName ()
@@ -86,6 +101,8 @@ public function getCheckName()
86101 }
87102
88103 /**
104+ * Get the reason, or `null` if there is no reason.
105+ *
89106 * @return string|null
90107 */
91108 public function getReason ()
0 commit comments