PHPackages                             elipettingale/wordpress-transformation - 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. elipettingale/wordpress-transformation

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

elipettingale/wordpress-transformation
======================================

A package to easily transform data by creating transformer classes (wordpress version)

v1.1.5(5y ago)2391MITPHP

Since Feb 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/elipettingale/wordpress-transformation)[ Packagist](https://packagist.org/packages/elipettingale/wordpress-transformation)[ RSS](/packages/elipettingale-wordpress-transformation/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (11)Used By (0)

Transformation
==============

[](#transformation)

A package to easily transform data using transformer classes. The idea behind this package is to be able to take data in one format and return it in a different or stripped down format. For example, you might use this when you are making an api endpoint and don't want to return everything or want to return something in multiple formats.

This is the wordpress version of this package. There is also a generic version here:

How to Install
--------------

[](#how-to-install)

Just install the package using composer:

```
composer require elipettingle/wordpress-transformation

```

How to Use
----------

[](#how-to-use)

The wordpress version of this package includes all the functionality of the generic version, but also works with custom post types and acf fields. Please refer to the readme for the generic package for detailed instructions on how to use this package: .

The following are specific to the wordpress version of the package.

### Post Transformer

[](#post-transformer)

The Post Transformer can be used in place of the regular transformer class, you can then use this to transform posts or custom post types. It includes compatibility with ACF. A Post Transformer will return a subset of the base wordpress attributes (all attributes are available using $includes) and any acf fields it has.

For example the following transformer:

```
class TeamMemberTransformer extends PostTransformer
{

}

```

Might return the following:

```
[
    'ID' => 108,
    'post_title' => 'Brandyn Sporer',
    'post_date' => '2020-02-05 09:27:57'
    'post_status' => 'publish'
    'post_content' => ' Ut beatae et hic eum deserunt sit nihil. Asperiores consequatur quo et quia minus impedit modi voluptas. Consectetur ex voluptatem maiores. Ex ut sint sequi et minus. Molestias dolorem officia consectetur quia. Placeat voluptatem earum error aut dolores doloremque. Sed officiis quod eum saepe at a. Maxime omnis aut deserunt eveniet sit voluptas voluptas. '
    'job_title' => 'Airframe Mechanic'
    'department' => 'Logistics'
    'address' => [
        'address' => '353 Little Bourke St, Melbourne VIC 3000, Australia'
        'lat' => -37.8134498
        'lng' => 144.9622691
        'zoom' => 14
        'place_id' => 'ChIJZdO0OLVC1moReE9bPKvo0UQ'
        'street_number' => '353'
        'street_name' => 'Little Bourke Street'
        'street_name_short' => 'Little Bourke St'
        'city' => 'Melbourne;
        'state' => 'Victoria'
        'state_short' => 'VIC'
        'post_code' => '3000'
        'country' => 'Australia'
        'country_short' => 'AU'
    ],
    'permalink' => 'http://wordpress.test/2020/02/05/brandyn-sporer/'
]

```

### Jam Packed Example

[](#jam-packed-example)

Here is an example using everything at your disposal:

```
class AddressTransformer extends Transformer
{
    protected $includes = [
        'address',
        'coordinates'
    ];

    protected $rename = [
        'address' => 'full_address'
    ];

    public function getCoordinatesAttribute()
    {
        return [
            'lat' => $this->item['lat'],
            'lng' => $this->item['lng']
        ];
    }
}

class TeamMemberTransformer extends PostTransformer
{
    protected $includes = [
        'post_title',
        'first_name',
        'last_name',
        'initials',
        'address'
    ];

    protected $rename = [
        'post_title' => 'full_name'
    ];

    public function getFirstNameAttribute()
    {
        return explode(' ', $this->item->post_title)[0];
    }

    public function getLastNameAttribute()
    {
        return explode(' ', $this->item->post_title)[1];
    }

    public function getInitialsAttribute()
    {
        return $this->getFirstNameAttribute()[0] . $this->getLastNameAttribute()[0];
    }

    public function getAddressAttribute()
    {
        return Transform::one($this->item->address, AddressTransformer::class);
    }
}

$query = new WP_Query([
    'post_type' => 'team_member'
]);

$team_members = $query->get_posts();
$team_members = Transform::all($team_members, TeamMemberTransformer::class);

```

Using the same data as above this would return:

```
[
    'full_name' => 'Brandyn Sporer',
    'first_name' => 'Brandyn',
    'last_name' => 'Sporer',
    'initials' => 'BS',
    'address' => [
        'full_address' => '353 Little Bourke St, Melbourne VIC 3000, Australia',
        'coordinates' => [
            'lat' => -37.8134498,
            'lng' => 144.9622691
        ]
    ]
]

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~52 days

Recently: every ~86 days

Total

9

Last Release

1911d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9060130?v=4)[Elliot Pettingale](/maintainers/elipettingale)[@elipettingale](https://github.com/elipettingale)

---

Top Contributors

[![elipettingale](https://avatars.githubusercontent.com/u/9060130?v=4)](https://github.com/elipettingale "elipettingale (16 commits)")

### Embed Badge

![Health badge](/badges/elipettingale-wordpress-transformation/health.svg)

```
[![Health](https://phpackages.com/badges/elipettingale-wordpress-transformation/health.svg)](https://phpackages.com/packages/elipettingale-wordpress-transformation)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
