https://github.com/astronati/php-wordpress-api-response-parser
Allows to map responses provided by any Wordpress API
https://github.com/astronati/php-wordpress-api-response-parser
php7 wordpress wordpress-api wordpress-php-library wp
Last synced: 10 months ago
JSON representation
Allows to map responses provided by any Wordpress API
- Host: GitHub
- URL: https://github.com/astronati/php-wordpress-api-response-parser
- Owner: astronati
- License: mit
- Created: 2018-05-02T22:28:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-30T10:51:57.000Z (about 3 years ago)
- Last Synced: 2025-03-24T15:41:50.832Z (10 months ago)
- Topics: php7, wordpress, wordpress-api, wordpress-php-library, wp
- Language: PHP
- Homepage: https://astronati.github.io/php-wordpress-api-response-parser/
- Size: 70.3 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://travis-ci.org/astronati/php-sports-open-data-response-parser)
[](https://www.codacy.com/app/astronati/php-wordpress-api-response-parser?utm_source=github.com&utm_medium=referral&utm_content=astronati/php-wordpress-api-response-parser&utm_campaign=Badge_Grade)
[](https://www.codacy.com/app/astronati/php-wordpress-api-response-parser?utm_source=github.com&utm_medium=referral&utm_content=astronati/php-wordpress-api-response-parser&utm_campaign=Badge_Coverage)
[](https://packagist.org/packages/astronati/wordpress-api-response-parser)
[](https://packagist.org/packages/astronati/wordpress-api-response-parser)
# Wordpress API Response Parser
Allows to map responses provided by Wordpress API.
## Supported Responses
Not all responses are currently supported but we are happy to work for you if you need some of them.
**NOTE:** To add another response into the supported list, please file a new issue.
To do that please file a new [issue](https://github.com/astronati/php-wordpress-api-response-parser/issues/new).
## Installation
You can install the library and its dependencies using `composer` running:
```sh
$ composer require astronati/wordpress-api-response-parser
```
### Usage
The library allows to return a model per each response and its content (post, tag, category, etc...).
##### Example
The following snippet can be helpful:
```php
use WARP\Response\ResponseParser;
...
// Obtain a Response
$apiResponse = ['id' => 123, ...] // Save the response from a Wordpress API
$response = ResponseParser::create($apiResponse, ResponseParser::CREATE_POST);
...
// Get post
$post = $response->getPost();
echo $post->getID(); // 123
```
For more details please take a look at [Response](https://github.com/astronati/php-wordpress-api-response-parser/tree/master/src/Response).
## Development
The environment requires [phpunit](https://phpunit.de/), that has been already included in the `dev-dependencies` of the
`composer.json`.
### Dependencies
To install all modules you just need to run following command:
```sh
$ composer install
```
### Testing
Tests files are created in dedicates folders that replicate the
[src](https://github.com/astronati/php-wordpress-api-response-parser/tree/master/src) structure as follows:
```
.
+-- src
| +-- [folder-name]
| | +-- [file-name].php
| ...
+-- tests
| +-- [folder-name]
| | +-- [file-name]Test.php
```
Execute following command to run the tests suite:
```sh
$ composer test
```
Run what follows to see the code coverage:
```sh
$ composer coverage
```
## License
This package is released under the [MIT license](LICENSE.md).