You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A. B. M. Mahmudul Hasan edited this page Apr 11, 2022
·
2 revisions
Something different?
You will get all the functionalities of Arrject here. Additionally you will also get some logical setter & getter.
Some example and explanation
$myArray = [];
$belt = new \AbmmHasan\Bucket\Functional\Belt($myArray);
// Set on Get function (will be applied during get)$belt->onGet("greet", function ($value) {
returntrim($value);
});
// set on Set function (will be applied during Set)$belt->onSet("email", function ($value) {
if (!filter_var($value, FILTER_VALIDATE_EMAIL)){
thrownew \Exception("Invalid email can't be set");
}
returnfilter_var($value, FILTER_SANITIZE_EMAIL);
});
// on Get example$belt->greet = ' hello';
echo$belt->greet; // output: 'hello'//on Set example$belt->email = 'abc.com'; // will throw exception during set, as it is invalid Email address