/contextual

Simple object-oriented contexts

Primary LanguagePHPMIT LicenseMIT

contextual

Simple object-oriented contexts

Build Status Code Quality Code Coverage Packagist Version

Usage

/**
 * @property boolean $JSON
 * @property boolean $admin
 * @property string  $type
 */
class ResponseContext extends \jmversteeg\contextual\Context
{

    // Declare default values with a preceding underscore
    
    private $_JSON  = false;
    private $_admin = false;
    private $_type  = 'body';

}

$responseContext = new ResponseContext([
    'JSON' => true,
    'type' => 'ajax'
]);

$responseContext->JSON;
// => true
$responseContext->admin;
// => false

$subContext = $responseContext->createSubContext([
    'admin' => true
]);

$subContext->JSON;
// => true
$subContext->admin;
// => true

License

MIT © JM Versteeg