PHP code example of inmanturbo / functional-library
1. Go to this page and download the library: Download inmanturbo/functional-library 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/ */
inmanturbo / functional-library example snippets
use Inmanturbo\FunctionalLibrary\HasFunctionalLibrary;
class ExampleLibrary
{
use HasFunctionalLibrary;
public static function library(bool $addOne = false, bool $addTwo = false)
{
return static::getLibrary(...func_get_args());
}
public static function closures()
{
return [
'addOne' => fn(int $number): int => $number + 1,
'addTwo' => fn(int $number): int => $number + 2,
];
}
}
[$addOne, $addTwo] = ExampleLibrary::library(addOne: true, addTwo: true);
expect($addOne(0))->toBe(1);
expect($addTwo(0))->toBe(2);
// Test a single option
$addOne = ExampleLibrary::library(addOne: true);
expect($addOne(0))->toBe(1);
// Test no options (should return all available options)
[$addOne, $addTwo] = ExampleLibrary::library();
expect($addOne(0))->toBe(1);
expect($addTwo(0))->toBe(2);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.