Simple object-oriented contexts
/**
* @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
MIT © JM Versteeg