1. Go to this page and download the library: Download axm/fluent library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$result = __(User::class)
->if(fn ($user) => $user->isAdmin())
->setProperty('type', 'admin')
->return('You are an admin.')
->elseif(fn ($user) => $user->isUser())
->setProperty('type', 'user')
->return('You are a user.')
->else()
->setProperty('type', 'unknown')
->return('You are not logged in.')
->get();
$result = __(new MyClass) //new instance
->method1()
->method2()
->new('SomeClass') //resets the previous intent with a new `FluentInterface` class to continue chaining.
->method1()
->method2()
->method3()
->new('OtherClass') //resets the previous intent with a new `FluentInterface` class to continue chaining.
->method1()
->method2()
->method3()
->get('method1'); //gets the value in this case of the return of method 1 of the last instance
$result = __(new MyClass)
->boot()
->getErrors()
->throwIf(fn ($user) => $fi->get('getError') > 0, , 'An error has occurred while initializing.')
$result = __(new MyClass)
->addCustomMethod('call', function ($obj) {
// Define your own logic here
})
->addCustomMethod('getName', function ($obj) {
// Define your own logic here
})
->call()
->getName()
->all();
class MiClase
{
public $value = 0;
public function increment($cantidad)
{
return $this->value += $cantidad;
}
public function duplicate()
{
return $this->value *= 2;
}
public function getValue()
{
return $this->value;
}
}
__($request->input()) //input array
->if(fn ($item) => $item['name'] === '')
->throwIf(true, 'The name field is ) // Create a new instance of the class 'Auth'.
->if(fn ($user) => $user->hasPermission('admin'))
->return(['Admin Dashboard', 'User Management','Role Management',])
->elseif(fn ($user) => $user->hasPermission('user'))
->return(['My Profile','My Orders','My Account',])
->else()
->return(['Login','Register',])
->get('return');