README

PSR-8 compliant implementation of Huggable Interfaces

Install

composer require psrly/huggables ^1

Usage

Using existing Hugger implementations

<?php require_once __DIR__ . '/vendor/autoload.php' ; use Psrly \ Hugger ; // all hugger implementations can be given an optional hug limit and name // simple silent hugger (no side effects, no state change) $ silent = new Hugger \ Silent ; // simple verbose hugger (writes to output on hugging) $ verbose = new Hugger \ Verbose ; $ verbose -> hug ( $ silent ); // -> "X is being hugged by Y" // -> "X is hugging back Y" // simple satisfiable hugger (increments satisfaction on hugging) $ satisfactionThreshold = 3 ; // satisfied after hugging three times $ satisfiable = Satisfiable ( $ satisfactionThreshold ); // hugged 0 times = not satisfied $ satisfiable -> isSatisfied (); // false $ satisfiable -> hug ( $ silent ); // hugged 1 time = not satisfied $ satisfiable -> isSatisfied (); // false $ satisfiable -> hug ( $ silent ); $ satisfiable -> hug ( $ silent ); // hugged 3 times = satisfied $ satisfiable -> isSatisfied (); // true

Creating your own Hugger implementation