-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestHook.php
40 lines (29 loc) · 1.22 KB
/
TestHook.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
require("PHook.php");
use Codestaq\PHook;
//Create an instance with the Defaults
$ph = new PHook\PHook;
//Simplest Hook
$ph->say("Running Hook ...")
->thenRun(function(){ echo " - Do Something Here - "; })
->andFinallySay("Done");
//Standard 3-Step Proccess with Colors ( Message -> Function -> Confirmation )
$ph->say("Getting a ")->red("Cup")->plain(" of Coffee")
->thenRun(function(){ echo " - Brewing Some Joe - ";})
->andFinallySay("Thats Some Good Coffee");
//Standard 4-Step Process with Colors ( Default 3 Steps + Error Message )
$ph->say("")->clear("Running ")->red("Impossible")->clear(" Function ... ")
->thenRun(function(){ return false; })
->thenSay("It Worked")
->unlessFails("The Function Failed")->white(" What a Surprise")->plain(" !!")
->apply();
//Hooks that only Runs on a specific Trigger Word (Trigger Hooks work with all the above formats aswell)
$ph->onTrigger("Commit")
->say("The Commit Message Has The Word '")->cyan("Commit")->plain("'")
->withoutACommand();
$ph->onTrigger("Second")
->say("The Commit Has The Word '")->cyan("Second")->plain("'")
->withoutACommand();
//Just Output no Function run (Like Above)
$ph->say("\nAll Done ")->cyan("Tests")->withoutACommand();
?>