trespass-php
Tired of isset()
and ?:
safety-guards? Access object properties and chain methods in a safe manner.
Installation
composer require rickwong/trespass
Usage
Simple:
use function Trespass\t;
t(null)->foo->•; // access undefined properties
t(false)->bar()->•; // call undefined methods
t([])->bar()['bat']->baz->•; // call undefined methods and then access undefined properties
Custom terminator:
$t = Trespass\createWrapper('__value');
$t($foo)->bar->__value;
Requirements
PHP 5.6+.
Community
Let's start one together! After you ★ this project, follow me @rygu on Twitter.
License
BSD 3-Clause license. Copyright © 2017, Rick Wong. All rights reserved.