jmversteeg/contextual

Simple object-oriented contexts

1.3.0 2016-07-04 15:53 UTC

This package is not auto-updated.

Last update: 2024-04-27 15:31:22 UTC


README

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