/
jagepard
/
PhpDesignPatterns-ChainOfResponsibility
Обзор
Документация
Войти
/
jagepard
/
PhpDesignPatterns-ChainOfResponsibility
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
run
35 строк
925 B
Jagepard
Major update
28 апр 2026, 16:35
28 апр 2026, 16:35
56e15dc
Код
Авторство
О чём код?
#!/usr/bin/env php <?php /** * @author : Jagepard <jagepard@yandex.ru> * @license https://mit-license.org/ MIT */ namespace Behavioral\ChainOfResponsibility; require_once "./vendor/autoload.php"; // Добавляем элементы в цепочку. $chain = [ new NoticeHandler(), new WarningHandler(), new ErrorHandler() ]; try { $handler = new ChainHandler($chain); printf("%s", "Call the handler by name:\n"); $handler->execute(NoticeHandler::class); $handler->execute(WarningHandler::class); $handler->execute(ErrorHandler::class); print "\n"; printf("%s", "Call all handlers in the chain before request by name:\n"); $handler->execute(NoticeHandler::class, true); $handler->execute(WarningHandler::class, true); $handler->execute(ErrorHandler::class, true); } catch (\Exception $e) { printf("%s", "Caught exception: " . $e->getMessage() . "\n"); }