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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static final function invalid_type($value, ?string $message=null): self {
|
|
|
|
$invalid_type = var_export($value, true).": invalid type";
|
|
|
|
if ($message !== null) $invalid_type .= ": $message";
|
|
|
|
return new static($invalid_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static final function invalid_callable($value, ?string $message=null): self {
|
|
|
|
$invalid_callable = var_export($value, true).": invalid callable";
|
|
|
|
if ($message !== null) $invalid_callable .= ": $message";
|
|
|
|
return new static($invalid_callable);
|
2023-11-24 16:50:05 +04:00
|
|
|
}
|
2023-11-09 10:03:35 +04:00
|
|
|
}
|