1. Go to this page and download the library: Download wp-forge/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/ */
wp-forge / fluent example snippets
use WP_Forge\Fluent\Fluent;
// Populate using an array
$fluent = new Fluent( [ 'a' => 1 ] );
var_dump( $fluent->toJson() ); // {"a":1}
// Populate using an object
$fluent = new Fluent( (object) [ 'b' => 2 ] );
var_dump( $fluent->toJson() ); // {"b":2}
// Populate using an iterable
$fluent = new Fluent( (function () { yield 1; yield 2; })() );
var_dump( $fluent->toJson() ); // [1,2]
$fluent = new \WP_Forge\Fluent\Fluent();
$fluent->isActive(); // Will set to true by default
var_dump( $fluent->toJson() ); // {"isActive":true}
$fluent->isActive( false );
var_dump( $fluent->toJson() ); // {"isActive":false}
$fluent = new \WP_Forge\Fluent\Fluent( ['isActive' => true] );
var_dump( $fluent->get( 'isActive' ) ); // true
// Since "isRegistered" doesn't exist, it returns the defined default value instead
var_dump( $fluent->get( 'isRegistered', 'Ask again later' ) ); // Ask again later
use WP_Forge\Fluent\Fluent;
$fluent = new Fluent( ['a' => 1] );
$fluent->toArray(); // Returns all data as an array
$fluent->toJson(); // Returns all data as JSON