PHPackages                             bridit/values - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bridit/values

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bridit/values
=============

Alter ego objects. Highly efficient way of building models, api clients and so on

0.6.1(5y ago)01463MITPHPPHP ^7.2|^8.0

Since Mar 18Pushed 5y agoCompare

[ Source](https://github.com/bridit/values)[ Packagist](https://packagist.org/packages/bridit/values)[ RSS](/packages/bridit-values/feed)WikiDiscussions main Synced 6d ago

READMEChangelogDependencies (1)Versions (25)Used By (3)

Supporting Opensource
---------------------

[](#supporting-opensource)

`formapro\values` is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our customers. If you'd like to join them, please consider:

- [Become our client](http://forma-pro.com/)
- [Become a sponsor](https://www.patreon.com/makasim)

---

[![Build Status](https://camo.githubusercontent.com/58949a3c64f26b2ac5d2a3d967e40fc60158c6bc11376c40abf47bb2011b1b09/68747470733a2f2f7472617669732d63692e6f72672f6d616b6173696d2f76616c7565732e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/makasim/values)

Your "alter ego" objects
========================

[](#your-alter-ego-objects)

The approach tries to gather the best from array and object worlds. So, with the library you can deal with object as you are used to but internally everything is stored into array. The array is easy to fetch out or set into of the object.

Could be used:

- interacting with [MongoDB](https://www.mongodb.com/) - [makasim/yadm](https://github.com/makasim/yadm).
- describing API clients - [formapro/telegram-bot](https://github.com/formapro/telegram-bot-php).
- describing domain models - [formapro/pvm](https://github.com/formapro/pvm)
- describing MQ messages.

**An object** provide us with a contract which is easy to rely on. We can type hint a class, use auto complete on its methods. That's a good part, but it is not easy or cheap to populate objects with data or take their current state. We have provide various tools like serializers, transformers and so on. Things are getting even worse when we have to deal with object trees.

**An array** on the other hand is easy store or send. Whenever you call an api or do a query to database you end up working with an array. That's a strong side but it does not gives any contract and code could be easily broken when array structure changes.

Examples
--------

[](#examples)

### Get repository info example

[](#get-repository-info-example)

Let's use [Github API](https://developer.github.com/v3/repos/#list-organization-repositories) and get info about [Symfony](https://github.com/symfony/symfony) repository. Here's the [real response](https://api.github.com/repos/symfony/symfony), we will use a shortened version.

```
