PHPackages                             spekkionu/property-access - 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. spekkionu/property-access

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

spekkionu/property-access
=========================

Trait that automatically calls getters and setters for property access.

0.4.0(11y ago)228MITPHPPHP &gt;=5.4.0

Since Apr 2Pushed 8y ago1 watchersCompare

[ Source](https://github.com/spekkionu/property-access)[ Packagist](https://packagist.org/packages/spekkionu/property-access)[ RSS](/packages/spekkionu-property-access/feed)WikiDiscussions master Synced 1mo ago

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

Property Access Trait
=====================

[](#property-access-trait)

[![Build Status](https://camo.githubusercontent.com/2fbc6779cd6ebeaf98f80066cba41cb3ae7c724e2f85e05ad1a77cabd675c1b3/68747470733a2f2f7472617669732d63692e6f72672f7370656b6b696f6e752f70726f70657274792d6163636573732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/spekkionu/property-access)[![Code Coverage](https://camo.githubusercontent.com/43333ca31fc251872cf6eb169d7cd0890c7000545ef4e3ba0ec6ef6e3ee57934/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370656b6b696f6e752f70726f70657274792d6163636573732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spekkionu/property-access/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/554d650107a4b313c267b429a5db13233245d99d3250786c3e3abc758c8606be/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370656b6b696f6e752f70726f70657274792d6163636573732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spekkionu/property-access/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/1fcfc750758596933650076dd177b1e90e51275536b7d59d37daee575564d46c/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f66303164616137662d623436642d343537352d616562382d3762653338383564343936372f6d696e692e706e67)](https://insight.sensiolabs.com/projects/f01daa7f-b46d-4575-aeb8-7be3885d4967)

Trait that automatically calls getters and setters for property access.

```
use Spekkionu\PropertyAccess\PropertyAccessTrait;

class ExampleClass
{
    use PropertyAccessTrait;

    private $name;

    private $email;

}
```

```
$example = new ExampleClass();

$example->name = 'Bob';
$example->email = 'bob@example.com';

echo $example->name; // Bob

$example->fill(array(
    'name' => 'Steve',
    'email' => 'steve@example.com'
));

echo $example->email; // steve@example.com
```

Getters and Setters will be called
----------------------------------

[](#getters-and-setters-will-be-called)

### You can even use Value Objects

[](#you-can-even-use-value-objects)

```
use Spekkionu\PropertyAccess\PropertyAccessTrait;

class ExampleClass
{
    use PropertyAccessTrait;

    private $name;

    private $email;

    public function setEmail(EmailAddress $email){
        $this->email = $email;
    }

}

// Value Object
class EmailAddress
{
    private $email;

    public function __construct($email)
    {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            throw new InvalidArgumentException('Not a valid email address.');
        }
        $this->email = $email;
    }

    public function getValue()
    {
        return $this->email;
    }

    public function __toString()
    {
        return $this->getValue();
    }
}

// Usage
$example = new ExampleClass();
$example->email = new EmailAddress('bob@example.com');
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

4065d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f47e67812cdd677cc4fd612e175bb651c2ae35e39d50c7592a815bf515cb12e5?d=identicon)[spekkionu](/maintainers/spekkionu)

---

Top Contributors

[![jonbernardi](https://avatars.githubusercontent.com/u/38191?v=4)](https://github.com/jonbernardi "jonbernardi (20 commits)")

---

Tags

gettersphpsettersaccesspropertygettersetter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/spekkionu-property-access/health.svg)

```
[![Health](https://phpackages.com/badges/spekkionu-property-access/health.svg)](https://phpackages.com/packages/spekkionu-property-access)
```

###  Alternatives

[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[antares/accessible

PHP library that allows you to define your class' getters, setters and constructor with docblock annotations.

123.9k1](/packages/antares-accessible)[usmanhalalit/get-set-go

Dynamic Setter-Getter for PHP 5.4+

1813.4k1](/packages/usmanhalalit-get-set-go)

PHPackages © 2026

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