nur-sery/src/schema/SchemaException.php

23 lines
701 B
PHP
Raw Normal View History

2023-11-09 10:03:35 +04:00
<?php
namespace nur\sery\schema;
use Exception;
class SchemaException extends Exception {
2023-11-24 22:36:33 +04:00
static final function invalid_schema(?string $message=null): self {
$invalid_schema = "invalid schema";
if ($message !== null) $invalid_schema .= ": $message";
return new static($invalid_schema);
}
2023-11-28 08:20:33 +04:00
static final function invalid_kind(string $kind, $value, ?string $message=null): self {
$invalid_kind = var_export($value, true).": invalid $kind";
if ($message !== null) $invalid_kind .= ": $message";
return new static($invalid_kind);
2023-11-24 22:36:33 +04:00
}
2023-11-28 08:20:33 +04:00
static final function invalid_type($value, ?string $message=null): self {
return self::invalid_kind("type", $value, $message);
2023-11-24 16:50:05 +04:00
}
2023-11-09 10:03:35 +04:00
}