modifs.mineures sans commentaires
This commit is contained in:
parent
f6c15f130a
commit
4753afdb2b
|
@ -21,12 +21,12 @@ abstract class _messenger {
|
||||||
|
|
||||||
static final function set_messenger_class(string $say_class, ?string $log_class=null) {
|
static final function set_messenger_class(string $say_class, ?string $log_class=null) {
|
||||||
if (!is_subclass_of($say_class, IMessenger::class)) {
|
if (!is_subclass_of($say_class, IMessenger::class)) {
|
||||||
throw ValueException::unexpected_class($say_class, IMessenger::class);
|
throw ValueException::invalid_class($say_class, IMessenger::class);
|
||||||
}
|
}
|
||||||
self::$say = new $say_class();
|
self::$say = new $say_class();
|
||||||
if ($log_class !== null) {
|
if ($log_class !== null) {
|
||||||
if (!is_subclass_of($log_class, IMessenger::class)) {
|
if (!is_subclass_of($log_class, IMessenger::class)) {
|
||||||
throw ValueException::unexpected_class($log_class, IMessenger::class);
|
throw ValueException::invalid_class($log_class, IMessenger::class);
|
||||||
}
|
}
|
||||||
self::$log = new $log_class();
|
self::$log = new $log_class();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
<?php
|
|
||||||
namespace nur\sery\schema;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
|
|
||||||
class ValueException extends Exception {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
static final function invalid_key($value, ?string $message=null): self {
|
|
||||||
return self::invalid_kind("key", $value, $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
static final function invalid_value($value, ?string $message=null): self {
|
|
||||||
return self::invalid_kind("value", $value, $message);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,9 +2,9 @@
|
||||||
namespace nur\sery\schema\_scalar;
|
namespace nur\sery\schema\_scalar;
|
||||||
|
|
||||||
use nulib\cl;
|
use nulib\cl;
|
||||||
|
use nulib\ValueException;
|
||||||
use nur\sery\schema\ref\ref_analyze;
|
use nur\sery\schema\ref\ref_analyze;
|
||||||
use nur\sery\schema\Result;
|
use nur\sery\schema\Result;
|
||||||
use nur\sery\schema\ValueException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ScalarResult: résultat de l'analyse ou de la normalisation d'une valeur
|
* Class ScalarResult: résultat de l'analyse ou de la normalisation d'une valeur
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
namespace nur\sery\schema\_scalar;
|
namespace nur\sery\schema\_scalar;
|
||||||
|
|
||||||
|
use nulib\ValueException;
|
||||||
use nur\sery\schema\input\Input;
|
use nur\sery\schema\input\Input;
|
||||||
use nur\sery\schema\ref\ref_analyze;
|
|
||||||
use nur\sery\schema\Result;
|
use nur\sery\schema\Result;
|
||||||
use nur\sery\schema\types\IType;
|
use nur\sery\schema\types\IType;
|
||||||
use nur\sery\schema\Value;
|
use nur\sery\schema\Value;
|
||||||
use nur\sery\schema\ValueException;
|
|
||||||
|
|
||||||
class ScalarValue extends Value {
|
class ScalarValue extends Value {
|
||||||
function __construct(ScalarSchema $schema, &$dest=null, $key=null, bool $verifix=true) {
|
function __construct(ScalarSchema $schema, &$dest=null, $key=null, bool $verifix=true) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
namespace nur\sery\schema\types;
|
namespace nur\sery\schema\types;
|
||||||
|
|
||||||
use nur\sery\schema\ValueException;
|
use nulib\ValueException;
|
||||||
|
|
||||||
class tcallable implements IType {
|
class tcallable implements IType {
|
||||||
static function ensure_callable(&$callable): void {
|
static function ensure_callable(&$callable): void {
|
||||||
if (!is_callable($callable)) throw ValueException::invalid_value($callable);
|
if (!is_callable($callable)) throw ValueException::unexpected_type($callable, "callable");
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ensure_ncallable(&$callable): void {
|
static function ensure_ncallable(&$callable): void {
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
Ce package contient des services généraux spécifiques à PHP
|
Ce package contient des services généraux spécifiques à PHP
|
||||||
|
|
||||||
exemples: func, UserException
|
exemples: func
|
||||||
|
|
||||||
-*- coding: utf-8 mode: markdown -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8:noeol:binary
|
-*- coding: utf-8 mode: markdown -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8:noeol:binary
|
Loading…
Reference in New Issue