Skip to content

Commit

Permalink
identify class name on checking required properties raised for easy d…
Browse files Browse the repository at this point in the history
…ebugging
  • Loading branch information
llaville committed Jul 2, 2024
1 parent 7df9a8d commit b24dd2b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Internal/JsonSerializable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
namespace Bartlett\Sarif\Internal;

use LogicException;
use function get_class;
use function is_numeric;
use function sprintf;

/**
* @author Laurent Laville
Expand Down Expand Up @@ -48,7 +50,9 @@ public function jsonSerialize(): array
$properties = [];
foreach ($this->required as $requirement) {
if (!isset($this->$requirement)) {
throw new LogicException('"' . $requirement . '" is required, but not defined.');
throw new LogicException(
sprintf('"%s.%s" is required, but not defined.', get_class($this), $requirement)
);
}
$properties[$requirement] = $this->$requirement;
}
Expand Down

0 comments on commit b24dd2b

Please sign in to comment.