liampm / swaddle
Swaddle acts as a wrapper around unknown collections of key-value pairs.
dev-master
2017-03-30 19:03 UTC
Requires
- php: ^7.0
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2025-04-21 17:05:22 UTC
README
Swaddle allows you to wrap collections of key-value pairs such as associative arrays and \stdClass
objects so that you can more easily access their properties and have more certainty of what properties do exist.
The aim of Swaddle is to reduce the amount of isset
or property_exists
checks.
Installation
$ composer require liampm/swaddle
Basic Usage
<?php use liampm\Swaddle; $configuration = json_decode(file_get_contents('config.json')); $swaddle = Swaddle::wrapObject($configuration); $swaddle->getProperty('count', 0);