Skip to content

Commit 2c35851

Browse files
committed
Exception docs
1 parent c35373c commit 2c35851

7 files changed

+39
-16
lines changed

src/Exception/CheckNotApplicableException.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@
77
use RuntimeException;
88

99
/**
10-
* Class CheckNotApplicableException
10+
* Represents the situation when a workshop developer tries to use a check in an exercise which has
11+
* a type not supported by the check.
12+
*
1113
* @package PhpSchool\PhpWorkshop\Exception
1214
* @author Aydin Hassan <aydin@hotmail.co.uk>
1315
*/
1416
class CheckNotApplicableException extends RuntimeException
1517
{
1618
/**
17-
* @param CheckInterface $check
18-
* @param ExerciseInterface $exercise
19+
* Static constructor to create an instance from the check & exercise.
20+
*
21+
* @param CheckInterface $check The check Instance.
22+
* @param ExerciseInterface $exercise The exercise Instance.
1923
* @return static
2024
*/
2125
public static function fromCheckAndExercise(CheckInterface $check, ExerciseInterface $exercise)

src/Exception/CliRouteNotExistsException.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
use RuntimeException;
66

77
/**
8-
* Class CliRouteNotExistsException
8+
* Represents the situation where a command is called which does not exist in the framework.
9+
*
910
* @package PhpSchool\PhpWorkshop\Exception
1011
* @author Aydin Hassan <aydin@hotmail.co.uk>
1112
*/
1213
class CliRouteNotExistsException extends RuntimeException
1314
{
1415
/**
15-
* @param string $routeName
16+
* @param string $routeName The name of the command which was typed.
1617
*/
1718
public function __construct($routeName)
1819
{

src/Exception/CodeExecutionException.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66
use Symfony\Component\Process\Process;
77

88
/**
9-
* Class CodeExecutionException
9+
* Represents the situation where some PHP code could not be executed successfully.
10+
*
1011
* @package PhpSchool\PhpWorkshop\Exception
1112
* @author Aydin Hassan <aydin@hotmail.co.uk>
1213
*/
1314
class CodeExecutionException extends RuntimeException
1415
{
1516
/**
16-
* @param Process $process
17+
* Static constructor to create an instance from a failed `Process` instance.
18+
*
19+
* @param Process $process The `Process` instance which failed.
1720
* @return static
1821
*/
1922
public static function fromProcess(Process $process)

src/Exception/ExerciseNotConfiguredException.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@
66
use RuntimeException;
77

88
/**
9-
* Class ExerciseNotConfiguredException
9+
* Represents the situation where an exercise requires a check but does not implement
10+
* the correct interface enforced by the check.
11+
*
1012
* @package PhpSchool\PhpWorkshop\Exception
1113
* @author Aydin Hassan <aydin@hotmail.co.uk>
1214
*/
1315
class ExerciseNotConfiguredException extends RuntimeException
1416
{
1517
/**
16-
* @param ExerciseInterface $exercise
17-
* @param $interface
18+
* Static constructor to create an instance from the exercise and interface name.
19+
*
20+
* @param ExerciseInterface $exercise The exercise instance.
21+
* @param $interface The FQCN of the interface.
1822
* @return static
1923
*/
2024
public static function missingImplements(ExerciseInterface $exercise, $interface)

src/Exception/InvalidArgumentException.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
namespace PhpSchool\PhpWorkshop\Exception;
44

55
/**
6-
* Class InvalidArgumentException
6+
* Represents invalid argument exceptions.
7+
*
78
* @package PhpSchool\PhpWorkshop\Exception
89
* @author Aydin Hassan <aydin@hotmail.co.uk>
910
*/
1011
class InvalidArgumentException extends \InvalidArgumentException
1112
{
1213
/**
14+
* Static constructor to create from the expected type & the actual value.
15+
*
1316
* @param string $expected
1417
* @param mixed $actual
1518
* @return static
@@ -26,6 +29,8 @@ public static function typeMisMatch($expected, $actual)
2629
}
2730

2831
/**
32+
* Static constructor to create from when a parameter should be one of a set of allowed values, but was not.
33+
*
2934
* @param string $parameterName
3035
* @param mixed[] $allowedValues
3136
* @param mixed $actualValue
@@ -47,7 +52,7 @@ public static function notValidParameter($parameterName, array $allowedValues, $
4752
* @param $value
4853
* @return string
4954
*/
50-
public static function stringify($value)
55+
private static function stringify($value)
5156
{
5257
if (is_object($value)) {
5358
return get_class($value);

src/Exception/MissingArgumentException.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
use RuntimeException;
66

77
/**
8-
* Class MissingArgumentException
8+
* Represents the situation where a command was called without required parameters.
9+
*
910
* @package PhpSchool\PhpWorkshop\Exception
1011
* @author Aydin Hassan <aydin@hotmail.co.uk>
1112
*/
@@ -17,8 +18,10 @@ class MissingArgumentException extends RuntimeException
1718
private $missingArguments = [];
1819

1920
/**
20-
* @param $commandName
21-
* @param array $missingArguments
21+
* Create the exception, requires the command name and missing arguments.
22+
*
23+
* @param string $commandName The command name.
24+
* @param array $missingArguments An array of missing arguments (strings)
2225
*/
2326
public function __construct($commandName, array $missingArguments)
2427
{
@@ -33,6 +36,8 @@ public function __construct($commandName, array $missingArguments)
3336
}
3437

3538
/**
39+
* Retrieve the list of missing arguments.
40+
*
3641
* @return array
3742
*/
3843
public function getMissingArguments()

src/Exception/SolutionExecutionException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
use RuntimeException;
66

77
/**
8-
* Class SolutionExecutionException
8+
* Represents the situation where a reference solution cannot be executed (this should only really happen during
9+
* workshop development).
910
* @author Aydin Hassan <aydin@hotmail.co.uk>
1011
*/
1112
class SolutionExecutionException extends RuntimeException

0 commit comments

Comments
 (0)