{"id":15707069,"url":"https://github.com/garyjones/php-type-converter","last_synced_at":"2025-05-12T19:26:41.293Z","repository":{"id":6596297,"uuid":"7839211","full_name":"GaryJones/php-type-converter","owner":"GaryJones","description":"Converts one resource to another (XML, JSON, Object, Array, Serialization).","archived":false,"fork":false,"pushed_at":"2015-07-18T15:19:57.000Z","size":164,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-04-01T02:41:24.233Z","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":"mojotech/pioneer","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GaryJones.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-26T15:08:20.000Z","updated_at":"2019-10-04T05:57:56.000Z","dependencies_parsed_at":"2022-07-09T11:46:27.305Z","dependency_job_id":null,"html_url":"https://github.com/GaryJones/php-type-converter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaryJones%2Fphp-type-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaryJones%2Fphp-type-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaryJones%2Fphp-type-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaryJones%2Fphp-type-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GaryJones","download_url":"https://codeload.github.com/GaryJones/php-type-converter/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253807302,"owners_count":21967335,"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","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-10-03T20:36:04.331Z","updated_at":"2025-05-12T19:26:41.274Z","avatar_url":"https://github.com/GaryJones.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Type Converter\n\nA class that handles the detection and conversion of certain resource formats / content types into other formats.\n\nThe current formats are supported: XML, JSON, Array, Object, Serialized\n\n## Requirements\n\n* PHP 5.3.0+\n* [SimpleXML](http://php.net/manual/book.simplexml.php) \n\n## Documentation\n\nThe class is pretty straight forward. If you want to convert something to another format, use the \"to\" methods.\n\n~~~php\n$object = TypeConverter::toObject($resource);\n$array = TypeConverter::toArray($resource);\n$json = TypeConverter::toJson($resource);\n$xml = TypeConverter::toXml($resource);\n$ser = TypeConverter::toSerialize($resource);\n~~~\n\nIf you want to detect what resource type it is, use the \"is\" methods.\nIf you use the \"to\" methods above, it does automatic \"is\" detection.\n\n~~~php\nTypeConverter::isObject($resource);\nTypeConverter::isArray($resource);\nTypeConverter::isJson($resource);\nTypeConverter::isXml($resource);\nTypeConverter::isSerialized($resource);\n~~~\n\nIf you want a string representation of what a resource is, use the default is() method.\n\n~~~php\n$resource = array();\nTypeConverter::is($resource); // array\n~~~\n\nYou can convert an XML document into an array (must have SimpleXML).\n\n~~~php\n$array = TypeConverter::xmlToArray($xml, TypeConverter::XML_MERGE);\n~~~\n\nWhen using xmlToArray(), you can define the format in which the node attributes and values are presented. The following constants are available.\n\n* `XML_NONE`  - Disregard XML attributes and only return the value.\n* `XML_MERGE` - Merge attributes and the value into a single dimension; the values key will be \"value\".\n* `XML_GROUP` - Group the attributes into a key of \"attributes\" and the value into a key of \"value\".\n* `XML_OVERWRITE` - Attributes will only be returned.\n\n## Status\n[![Build Status](https://travis-ci.org/GaryJones/php-type-converter.png)](https://travis-ci.org/GaryJones/php-type-converter)\n\n## Changelog\nOriginally forked from Type Converter v2.0.0 https://github.com/milesj/php-type_converter by [Miles Johnson](https://twitter.com/gearvOsh).\n\nThis fork adds support for conversion of nested combinations of arrays / objects and some unit tests.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaryjones%2Fphp-type-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaryjones%2Fphp-type-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaryjones%2Fphp-type-converter/lists"}