modifs.mineures sans commentaires
This commit is contained in:
parent
1c5674558b
commit
6dd7325fd1
|
@ -14,24 +14,6 @@ abstract class _messenger {
|
||||||
/** @var IMessenger */
|
/** @var IMessenger */
|
||||||
protected static $log;
|
protected static $log;
|
||||||
|
|
||||||
static final function set_messenger(IMessenger $say, ?IMessenger $log=null) {
|
|
||||||
self::$say = $say;
|
|
||||||
if ($log !== null) self::$log = $log;
|
|
||||||
}
|
|
||||||
|
|
||||||
static final function set_messenger_class(string $say_class, ?string $log_class=null) {
|
|
||||||
if (!is_subclass_of($say_class, IMessenger::class)) {
|
|
||||||
throw ValueException::invalid_class($say_class, IMessenger::class);
|
|
||||||
}
|
|
||||||
self::$say = new $say_class();
|
|
||||||
if ($log_class !== null) {
|
|
||||||
if (!is_subclass_of($log_class, IMessenger::class)) {
|
|
||||||
throw ValueException::invalid_class($log_class, IMessenger::class);
|
|
||||||
}
|
|
||||||
self::$log = new $log_class();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract static function get(): IMessenger;
|
abstract static function get(): IMessenger;
|
||||||
|
|
||||||
/** obtenir une nouvelle instance, avec un nouveau paramétrage */
|
/** obtenir une nouvelle instance, avec un nouveau paramétrage */
|
||||||
|
|
|
@ -1,12 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
namespace nur\sery\output;
|
namespace nur\sery\output;
|
||||||
|
|
||||||
|
use nulib\ValueException;
|
||||||
use nur\sery\output\std\ProxyMessenger;
|
use nur\sery\output\std\ProxyMessenger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class log: inscrire un message dans les logs uniquement
|
* Class log: inscrire un message dans les logs uniquement
|
||||||
*/
|
*/
|
||||||
class log extends _messenger {
|
class log extends _messenger {
|
||||||
|
static function set_messenger(IMessenger $log=null) {
|
||||||
|
self::$log = $log;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function set_messenger_class(string $log_class=null, ?array $params=null) {
|
||||||
|
if (!is_subclass_of($log_class, IMessenger::class)) {
|
||||||
|
throw ValueException::invalid_class($log_class, IMessenger::class);
|
||||||
|
}
|
||||||
|
self::$log = new $log_class($params);
|
||||||
|
}
|
||||||
|
|
||||||
static function get(): IMessenger {
|
static function get(): IMessenger {
|
||||||
if (self::$msg === null) {
|
if (self::$msg === null) {
|
||||||
$msg = self::$log;
|
$msg = self::$log;
|
||||||
|
|
|
@ -1,12 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
namespace nur\sery\output;
|
namespace nur\sery\output;
|
||||||
|
|
||||||
|
use nulib\ValueException;
|
||||||
use nur\sery\output\std\ProxyMessenger;
|
use nur\sery\output\std\ProxyMessenger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class msg: inscrire un message dans les logs ET l'afficher sur la console
|
* Class msg: inscrire un message dans les logs ET l'afficher sur la console
|
||||||
*/
|
*/
|
||||||
class msg extends _messenger {
|
class msg extends _messenger {
|
||||||
|
static function set_messenger(IMessenger $say, ?IMessenger $log=null) {
|
||||||
|
self::$say = $say;
|
||||||
|
if ($log !== null) self::$log = $log;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function set_messenger_class(string $say_class, ?string $log_class=null) {
|
||||||
|
if (!is_subclass_of($say_class, IMessenger::class)) {
|
||||||
|
throw ValueException::invalid_class($say_class, IMessenger::class);
|
||||||
|
}
|
||||||
|
self::$say = new $say_class();
|
||||||
|
if ($log_class !== null) {
|
||||||
|
if (!is_subclass_of($log_class, IMessenger::class)) {
|
||||||
|
throw ValueException::invalid_class($log_class, IMessenger::class);
|
||||||
|
}
|
||||||
|
self::$log = new $log_class();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static function get(): IMessenger {
|
static function get(): IMessenger {
|
||||||
if (self::$msg === null) {
|
if (self::$msg === null) {
|
||||||
$log = self::$log;
|
$log = self::$log;
|
||||||
|
|
|
@ -1,12 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
namespace nur\sery\output;
|
namespace nur\sery\output;
|
||||||
|
|
||||||
|
use nulib\ValueException;
|
||||||
use nur\sery\output\std\ProxyMessenger;
|
use nur\sery\output\std\ProxyMessenger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class say: afficher un message sur la console uniquement
|
* Class say: afficher un message sur la console uniquement
|
||||||
*/
|
*/
|
||||||
class say extends _messenger {
|
class say extends _messenger {
|
||||||
|
static function set_messenger(IMessenger $say) {
|
||||||
|
self::$say = $say;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function set_messenger_class(string $say_class, ?array $params=null) {
|
||||||
|
if (!is_subclass_of($say_class, IMessenger::class)) {
|
||||||
|
throw ValueException::invalid_class($say_class, IMessenger::class);
|
||||||
|
}
|
||||||
|
self::$say = new $say_class($params);
|
||||||
|
}
|
||||||
|
|
||||||
static function get(): IMessenger {
|
static function get(): IMessenger {
|
||||||
if (self::$msg === null) {
|
if (self::$msg === null) {
|
||||||
$msg = self::$say;
|
$msg = self::$say;
|
||||||
|
|
Loading…
Reference in New Issue