strukt / event
No event loop included!
Installs: 526
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^8.1
- strukt/base: v1.0.0
This package is not auto-updated.
Last update: 2025-01-10 21:46:10 UTC
README
This is not an event-loop
it has events and loops.
Events
//use Strukt\Event $credentials = array("username"=>"admin", "password"=>"p@55w0rd"); $login = Event::create(function($username, $password) use($credentials){ return $username == $credentials["username"] && $password == $credentials["password"]; }); $isLoggedIn = $login->apply("admin","p@55w0rd")->exec(); // $isLoggedIn = $login->applyArgs($credentials)->exec();
Reflector
// $r = Strukt\Ref::createFrom(new Payroll\User); $r = Strukt\Ref::create(Payroll\User::class); $r->getRef();//ReflectionClass //$r->noMake();//newInstanceWithoutConstructor $r->make("pitsolu");//newInstanceArgs $r->getInstance();//InstanceOf Payroll\AuthModule\Model\User $r->prop("id")->getRef();//ReflectionProperty $r->prop("id")->set(1); $r->prop("id")->get();//1 $r->method("getUsername")->invoke();//pitsolu $r->method("getUsername")->getRef(); //ReflectionMethod $r->method("getUsername")->getClosure();//Closure Strukt\Ref::func("array_sum")->invoke([1,2]);//3 Strukt\Ref::func("array_sum")->getRef();//ReflectionFunction
Loop
use Strukt\Loop; use Strukt\Cmd; Loop::add("auth", ["admin", "p@55w0rd"], function($username, $password){ echo sprintf("username:%s|password:%s\n", $username, $password); }); Loop::add("help", function(){ echo "Docs\n"; }); // Loop::add("hello", function($name){ // echo sprintf("Hello %s", $name); // }); Loop::run(); // Cmd::exec("help"); // Cmd::exec("auth", ["peter", "pazzw0rd"]); // Cmd::exec("hello", ["World"]);