{"id":18929514,"url":"https://github.com/thecodingmachine/metahydrator","last_synced_at":"2025-10-04T05:28:38.923Z","repository":{"id":57067869,"uuid":"84829001","full_name":"thecodingmachine/metahydrator","owner":"thecodingmachine","description":"A configurable implementation of mouf's Hydrator interface","archived":false,"fork":false,"pushed_at":"2018-11-09T22:09:39.000Z","size":58,"stargazers_count":6,"open_issues_count":2,"forks_count":5,"subscribers_count":1,"default_branch":"1.x","last_synced_at":"2025-09-30T05:47:10.664Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecodingmachine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-13T13:22:40.000Z","updated_at":"2021-09-21T19:09:51.000Z","dependencies_parsed_at":"2022-08-24T14:54:08.212Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/metahydrator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thecodingmachine/metahydrator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fmetahydrator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fmetahydrator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fmetahydrator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fmetahydrator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/metahydrator/tar.gz/refs/heads/1.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fmetahydrator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278267342,"owners_count":25958828,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T11:33:20.626Z","updated_at":"2025-10-04T05:28:38.876Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/thecodingmachine/metahydrator/v/stable)](https://packagist.org/packages/thecodingmachine/metahydrator)\n[![Total Downloads](https://poser.pugx.org/thecodingmachine/metahydrator/downloads)](https://packagist.org/packages/thecodingmachine/metahydrator)\n[![Latest Unstable Version](https://poser.pugx.org/thecodingmachine/metahydrator/v/unstable)](https://packagist.org/packages/thecodingmachine/metahydrator)\n[![License](https://poser.pugx.org/thecodingmachine/metahydrator/license)](https://packagist.org/packages/thecodingmachine/metahydrator)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/thecodingmachine/metahydrator/badges/quality-score.png?b=1.x)](https://scrutinizer-ci.com/g/thecodingmachine/metahydrator/?branch=1.x)\n[![Build Status](https://travis-ci.org/thecodingmachine/metahydrator.svg?branch=1.x)](https://travis-ci.org/thecodingmachine/metahydrator)\n[![Coverage Status](https://coveralls.io/repos/thecodingmachine/metahydrator/badge.svg?branch=1.x\u0026service=github)](https://coveralls.io/github/thecodingmachine/metahydrator?branch=1.x)\n\n# About hydrating\n\nThis package aims to help handling raw data (associative arrays of basic types) for editing and creating instances of\nwhatever-the-class-you-want.\nTherefore, a class offering a solution to this purpose should implement interface `Hydrator`, ie methods `hydrateObject`\nand `hydrateNewObject`.\n- method `hydrateNewObject` should create an instance of requested class, using parsed data to set its values.\n- method `hydrateObject` should edit a given object, setting its properties using parsed data.\nThis package offers a generic  implementation of `Hydrator`, `MetaHydrator`, designed to work specifically with\n[Mouf](http://mouf-php.com/).\n\n## How to use?\n\nThe main interest of this package is to avoid unpleasant and interminable hours of writing repetitive lines of code to\ndescribe how to manage some innput data (ie validate, parse and instantiate from it), and instead make the creation of a\ndata handler a simple configuration task. Configuration, or should I use the terms \"dependency injection\". This is where\nthe power of Mouf comes particularly handy: this tool, featuring present library, will allow you to create your data\nparsers/validators with only drag/drop/naming action, occasionally writing little pieces of code (if you wish to implement\nyour own atomic parsers or validators), but without duplication.\n\n## How does it work?\n\n### Data parsing\n\nClass `MetaHydrator` uses instances of `HydratingHandlerInterface` to parse and validate raw input. Such an instance should\nparse specific key(s) in input array (using a configured instance of `ParserInterface`), and may throw an exception\n(`Invalid`).\nIn `SimpleHydratingHandler` implementation of `HydratingHandlerInterface`, one specific key in input array data is handled,\nie the value located at that key is parsed and, if parsing was successful, parsed value is validated. Keep in mind that this\nvalidation should not consider other parsed values, since a handler does not wait for all values to be parsed before\nchecking for its handled value sanity.\n\n### Data validation\n\nAn implementation of interface `ValidatorInterface` must implement method `validate`; this method will do nothing if input\ndata is correct, and shall throw a `InvalidValueException` if it is not. Such an exception needs an `innerErrorsMap` when\nconstructed. A well-formed errors map should be an associative array, keys being strings, and values each being either a\ndescriptor of the field error (such as a `DetailedErrorMessage`, for instance) or a well-formed errors map. More precisely,\nits structure should be consistent with input data, where invalid fields would be replaced by those error descriptors.\n\n### Applying parsed data\n\nUsing an inner simple hydrator (by default, TDBMHydrator seems to be a good choice), the parsed data can finally be used\nin two different ways: You can whether apply it to an already existing object, (using implementation of method `hydrateObject`)\nof your hydrator, or create a new instance of the class you wish to instanciate (method `hydrateNewObject`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fmetahydrator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fmetahydrator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fmetahydrator/lists"}