PHPackages                             vertigolabs/data-aware - 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. vertigolabs/data-aware

ActiveLibrary

vertigolabs/data-aware
======================

A library to give useful input data handling to your objects

1.0.3(1y ago)08261MITPHPPHP &gt;=8.0.0CI failing

Since Jun 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jaimz22/DataAware)[ Packagist](https://packagist.org/packages/vertigolabs/data-aware)[ RSS](/packages/vertigolabs-data-aware/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (1)

VertigoLabs Data Aware
======================

[](#vertigolabs-data-aware)

DataAware provides a unique and consistent method of dynamic data handling.

Dependencies
------------

[](#dependencies)

- Symfony's PropertyAccess component is used. You may install it via Composer using `composer require symfony/property-access`.

Features
--------

[](#features)

- Retrieve a specific data item or the full data set.
- Set and merge data into the class.
- Check for the existence of a data item.
- Apply default values to missing data.
- Normalize data keys into camelCase format.

Methods
-------

[](#methods)

### setData($data, $normalize = true, $applyDefaults = true)

[](#setdatadata-normalize--true-applydefaults--true)

Set the data for the class. This method accepts three parameters:

**Parameters:**

`$data`: The data to be managed by the class. It is expected to be an array.

`$normalize` (optional): This is a boolean parameter that indicates whether the keys in the `$data` array should be normalized into camelCase format. The default value is `true`, which means the keys will be normalized by default unless specified otherwise.

`$applyDefaults` (optional): This is also a boolean parameter. If set to `true`, the method will apply default values for any keys in the `$data` array that aren't already set. The default value of this parameter is `true`.

This method sets the data for the class while considering the provided normalization and defaulting parameters.

### mergeData($data, $normalize = true, $applyDefaults = true)

[](#mergedatadata-normalize--true-applydefaults--true)

This method merges new data into the existing data set.

**Parameters:**

`$data`: The new data to merge into the existing data set. It should be an array.

`$normalize` (optional): This is a boolean parameter that dictates whether the keys in the `$data` array should be normalized into camelCase format. The default value is `true`, which means the keys will be normalized by default unless specified otherwise.

`$applyDefaults` (optional): This is also a boolean parameter. If set to `true`, the method will apply default values for any keys in the `$data` array that aren't already set. The default value of this parameter is also `true`.

Merges new data into the existing data set. This method accepts the same parameters as `setData()`.

### getData($key = null, $default = null)

[](#getdatakey--null-default--null)

Retrieve specific, all, or a subset of processed data. This method accepts one optional parameter:

**Parameters:**

`$key` (optional): This is a parameter that accepts the key for the specific piece of data you want to retrieve. If this parameter is not provided or null, the method will retrieve all the data.

`$default` (optional): This is a parameter that allows you to provide a default value, which will be returned if the specified key does not exist in the data. This parameter defaults to `null`.

### getRawData($key = null, $default = null)

[](#getrawdatakey--null-default--null)

Retrieve specific, all, or a subset of raw (unprocessed) data. This method accepts two optional parameters:

**Parameters:**

`$key` (optional): This is a parameter that accepts the key for the specific piece of data you want to retrieve from the raw data set. If this parameter is not provided or null, the method will retrieve all the raw data.

`$default` (optional): This is a parameter that allows you to provide a default value, which will be returned if the specified key does not exist in the raw data. This parameter defaults to `null`.

### hasData($key)

[](#hasdatakey)

Check for the existence of a data item in the processed data set. This method requires one parameter:

**Parameter:**

`$key`: This is the key of the specific data item you want to check. It should be a string value. If the key exists in the processed data set, the method returns `true`. Otherwise, it returns `false`.

### hasRawData($key)

[](#hasrawdatakey)

This method checks for the existence of a data item in the raw data set. It requires one parameter:

**Parameter:**

`$key`: This is a string value representing the key of the specific data item you want to verify the existence of in the raw data set. If the key exists in the raw data set, the method returns `true`. Otherwise, it returns `false`.

Exceptions
----------

[](#exceptions)

Throws a `DataNotFoundNoDefaultException` when trying to access a non-existent key and no default is provided.

How to use
----------

[](#how-to-use)

Here's a simple example of how to use this trait in your class:

```
use VertigoLabs\DataAware\DataAwareTrait;
use VertigoLabs\DataAware\DataAwareInterface;

class EmployeeProfile implements DataAwareInterface
{
use DataAwareTrait;

    public function __construct(array $data)
    {
        $defaults = [
            'firstName' => 'Not provided',
            'lastName' => 'Not provided',
            'email' => 'Not provided'
        ];

        // Merging incoming data with defaults
        $data = array_merge($defaults, $data);

        $this->setData($data);
    }

    public function displayProfile()
    {
        foreach ($this->getData() as $key => $value) {
            echo ucfirst($key) . ": " . $value . "\n";
        }
    }

}

// Instantiate an EmployeeProfile with some initial data
$employee = new EmployeeProfile([
    'firstName' => 'John',
    'email' => 'john.doe@example.com'
]);

// Display the profile
$employee->displayProfile();

// Merge new data into the profile
$employee->mergeData([
    'lastName' => 'Doe',
    'position' => 'Software Developer',
    'address'=>[
        'street'=>'123 Main St',
        'city'=>'Anytown',
        'state'=>'NY','zip'=>'12345'
    ]
]);

// Display the updated profile
$employee->displayProfile();

// Retrieve a specific piece of data
echo "First Name: " . $employee->getData('firstName') . "\n";

// Check for the existence of a specific piece of data
echo "Does the profile have a position? " . ($employee->hasData('position') ? 'Yes' : 'No') . "\n";

// Use dot notation to retieve data from nested arrays
echo "City: " . $employee->getData('address.city') . "\n";

// Retrieve an an array of a subset of data
$name = $employee->getData(['firstName', 'lastName']);

// Display the subset of data
echo "Name: " . $name['firstName'] . " " . $name['lastName'] . "\n";

// Create an array of a subset of data with custom key names
$address = $employee->getData([
    'line1' => 'address.street',
    'locality' => 'address.city',
    'region' => 'address.state',
    'postalCode' => 'address.zip'
]);

// Display the custom subset of data
echo "Address: " . $address['line1'] . "\n";
echo "City: " . $address['locality'] . "\n";
echo "State: " . $address['region'] . "\n";
echo "Zip: " . $address['postalCode'] . "\n";
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance50

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~473 days

Total

4

Last Release

368d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/53254d08df6c002757411c25e1c1c3fd6af315db3f05c22859050b16aed1ba1c?d=identicon)[jaimz22](/maintainers/jaimz22)

---

Top Contributors

[![jaimz22](https://avatars.githubusercontent.com/u/5921193?v=4)](https://github.com/jaimz22 "jaimz22 (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vertigolabs-data-aware/health.svg)

```
[![Health](https://phpackages.com/badges/vertigolabs-data-aware/health.svg)](https://phpackages.com/packages/vertigolabs-data-aware)
```

###  Alternatives

[symfony/form

Allows to easily create, process and reuse HTML forms

2.8k152.1M2.8k](/packages/symfony-form)[symfony/security-http

Symfony Security Component - HTTP Integration

1.7k164.3M234](/packages/symfony-security-http)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k48.1M236](/packages/api-platform-core)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[vich/uploader-bundle

Ease file uploads attached to entities

1.9k25.9M116](/packages/vich-uploader-bundle)

PHPackages © 2026

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