PHP code example of sauls / options-resolver

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

    

sauls / options-resolver example snippets


$resolver->setDefined['nested.name', 'nested.value', 'nested.deep.type'];

$resolver->addAllowedType('nested.name', ['string']);
$resolver->addAllowedType('nested.value', ['int']);

$resolver->addAllowedValues('nested.deep.type', ['one', 'two', 'three']);


$resolver->setDefaults(
    [
        'nested.name' => 'Hello world!',
        'nested.value' => 100,
        'nested.deep.type' => 'one',
    ]
);

// Or

$resolver->setDefaults(
    [
        'nested' => [
            'name' => 'Hello world!',
            'value' => 100,
            'deep' => [
                'type' => 'one',
            ],
        ],
    ]
);


$resolver->resolve(
    [
        'nested.name' => 'Resolve me!',
        'nested.value' => 500,
        'nested.deep.type' => 'two',
    ]
);

// Or

$resolver->resolve(
    [
        'nested' => [
            'name' => 'Resolve me!',
            'value' => 500,
            'deep' => [
                'type' => 'two',
            ],
        ]
    ]
);