Skip to content

Commit 45507ad

Browse files
committed
Add missing exceptions
1 parent 5f506e4 commit 45507ad

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace NathanDunn\StateHistory\Exceptions;
4+
5+
use Exception;
6+
7+
class InvalidStateMachineConfigurationException extends Exception
8+
{
9+
public function __construct(
10+
string $field,
11+
mixed $config,
12+
?string $modelClass = null
13+
) {
14+
$modelInfo = $modelClass ? " for {$modelClass}" : '';
15+
$configType = is_object($config) ? get_class($config) : gettype($config);
16+
$message = "Invalid state machine configuration for field '{$field}'{$modelInfo}. " .
17+
"Expected string or array with 'machine' key, got {$configType}.";
18+
19+
parent::__construct($message);
20+
}
21+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace NathanDunn\StateHistory\Exceptions;
4+
5+
use Exception;
6+
7+
class NoStateMachineConfiguredException extends Exception
8+
{
9+
public function __construct(
10+
string $field,
11+
?string $modelClass = null
12+
) {
13+
$modelInfo = $modelClass ? " for {$modelClass}" : '';
14+
$message = "No state machine configured for field '{$field}'{$modelInfo}.";
15+
16+
parent::__construct($message);
17+
}
18+
}

0 commit comments

Comments
 (0)