Skip to content

This is an example of the Chain of Responsibility pattern. I'm using a simple DTO "HomeStatus" to store values statically as an example.

Notifications You must be signed in to change notification settings

frankperez87/chain-of-responsibility-pattern-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Chain of Responsibility Pattern in PHP

This is an example of the Chain of Responsibility pattern. I'm using a simple DTO "HomeStatus" to store values statically as an example.

Example Usage

<?php

require 'vendor/autoload.php';

$locks = new Locks;
$lights = new Lights;
$alarm = new Alarm;

$locks->succeedWith($lights);
$lights->succeedWith($alarm);

try {
    $locks->check(new HomeStatus);
    echo 'Your home is secure.';
} catch (Exception $e) {
    echo $e->getMessage();
}

About

This is an example of the Chain of Responsibility pattern. I'm using a simple DTO "HomeStatus" to store values statically as an example.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages