PHP code example of icecave / flip

1. Go to this page and download the library: Download icecave/flip 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/ */

    

icecave / flip example snippets


use Icecave\Flip\FlagSetTrait;

final class ExampleFlags
{
    use FlagSetTrait;

    private $foo = true;
    private $bar = false;
    private $baz = false;
}

$flags = ExampleFlags::none()
    ->bar(true)
    ->baz(true);

$flags = ExampleFlags::defaults()
    ->foo(false)
    ->bar(true);

$flags = ExampleFlags
    ::foo(false)
    ->bar(true);

function dumpFlags(ExampleFlags $flags)
{
    if ($flags->foo) {
        echo 'Foo is enabled!';
    } else {
        echo 'Foo is disabled!';
    }

    if ($flags->bar) {
        echo 'Bar is enabled!';
    } else {
        echo 'Bar is disabled!';
    }

    if ($flags->baz) {
        echo 'Baz is enabled!';
    } else {
        echo 'Baz is disabled!';
    }
}