astronati/wordpress-api-response-parser

Allows to map responses provided by any Wordpress API.

2.1.0 2022-10-30 10:51 UTC

This package is auto-updated.

Last update: 2024-03-29 03:32:28 UTC


README

Build Status Codacy Badge Codacy Badge Latest Stable Version License

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.

Installation

You can install the library and its dependencies using composer running:

$ 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:

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.

Development

The environment requires phpunit, 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:

$ composer install

Testing

Tests files are created in dedicates folders that replicate the 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:

$ composer test

Run what follows to see the code coverage:

$ composer coverage

License

This package is released under the MIT license.