endroid/property-access

Endroid Property Access

Fund package maintenance!
endroid

2.4.0 2024-10-20 19:23 UTC

README

By endroid

Latest Stable Version Build Status Total Downloads Monthly Downloads License

Extends the Symfony property accessor with the ability to filter on objects using the expression language component. An example of such a query would be band.member[address.street=="Abbey Road"].firstName. This functionality makes it easier to retrieve properties without the need for looping through values.

Great advantage of this approach is the possibility of specifying conditional mapping via configuration instead of code.

Installation

Use Composer to install the library.

$ composer require endroid/property-access

Usage

<?php

use Endroid\PropertyAccess\PropertyAccessor;

$accessor = new PropertyAccessor();

// Returns the first name of the first band member that lives on Abbey Road
$firstName = $accessor->getValue($band, 'member[address.street=Abbey Road][0].firstName');

Versioning

Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatibility breaking changes will be kept to a minimum but be aware that these can occur. Lock your dependencies for production and test your code when upgrading.

License

This bundle is under the MIT license. For the full copyright and license information please view the LICENSE file that was distributed with this source code.