PHPackages                             actualwave/object - 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. actualwave/object

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

actualwave/object
=================

Non dynamic base Object class with getters/setters implementation

0.0.5(10y ago)01062MITPHPPHP &gt;=7.0.0

Since Dec 3Pushed 10y ago1 watchersCompare

[ Source](https://github.com/burdiuz/php-object)[ Packagist](https://packagist.org/packages/actualwave/object)[ Docs](https://github.com/burdiuz/php-object)[ RSS](/packages/actualwave-object/feed)WikiDiscussions master Synced 2mo ago

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

PHP-Object
----------

[](#php-object)

[![Build Status](https://camo.githubusercontent.com/e04ec2f971036d913cb4d1da86f5cb19027642d64f8f15b53c863dc07be3c6ff/68747470733a2f2f7472617669732d63692e6f72672f6275726469757a2f7068702d6f626a6563742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/burdiuz/php-object)[![Coverage Status](https://camo.githubusercontent.com/80ebf0cfcc25bb18c102562e75c0c6a53590e3ae7aded7ea78748732a46fa4c3/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6275726469757a2f7068702d6f626a6563742f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/burdiuz/php-object?branch=master)[![Dependency Status](https://camo.githubusercontent.com/a02f325a318d902ab2717c14aa3faa4e1a643e827c4e62952971224f44607fb5/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3536386135366563656234663437303033633030313030372f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/568a56eceb4f47003c001007)[![Latest Stable Version](https://camo.githubusercontent.com/d502032e1958c9c6e99ea05caa90e5934c3545a9c86c9a46b8f792fd29cc543b/68747470733a2f2f706f7365722e707567782e6f72672f61637475616c776176652f6f626a6563742f762f737461626c65)](https://packagist.org/packages/actualwave/object) [![Total Downloads](https://camo.githubusercontent.com/57e65e5b50ff6f4fcfe148e48c82f4b0b0becf2945f37a41decbb01c64b23271/68747470733a2f2f706f7365722e707567782e6f72672f61637475616c776176652f6f626a6563742f646f776e6c6f616473)](https://packagist.org/packages/actualwave/object) [![License](https://camo.githubusercontent.com/0137a633a3dc5378a1ac895bbec375b490b7001525a7450113c01f8bc2ca5b23/68747470733a2f2f706f7365722e707567782e6f72672f61637475616c776176652f6f626a6563742f6c6963656e7365)](https://packagist.org/packages/actualwave/object)

Non dynamic base object class for PHP. Allows making getters and setters via `get*` and `set*` methods with public/protected accessor. Not defined properties will throw error.

### Installation

[](#installation)

Via [composer](https://getcomposer.org/)

```
composer require actualwave/object

```

### Usage

[](#usage)

Basically instead of shared magic methods `__set`, `__get`, `__isset`, `__unset` you can define individual methods for each property:

- get\* - get\[Property name from upper-case char\], for reading property value.
- set\* - set\[Property name from upper-case char\], for setting property new value.
- has\* - has\[Property name from upper-case char\], for checking is property set.
- remove\* - remove\[Property name from upper-case char\], for removing(using `unset()` on it) property.

`has*` and `remove*` methods have default action and are optional. By default, `has*` will always return `true` for properties with defined getter and `remove*` will try to pass `null` into setter.

```
class MyObject extends \aw\Object {
    private $_property = null;
    public function getProperty(){
        return 'GET-'.$this->_property;
    }
    public function setProperty($value){
        $this->_property = 'SET-'.$value;
    }
    public function getData(){
        return 'DATA:'.$this->hiddenProperty;
    }
    protected function getHiddenProperty(){
        return 'hidden value';
    }
}
```

Instances of `MyObject` will be non-dynamic objects with one read-write property `property` that can be accessed via `$instance->property` and two read-only properties -- `hiddenProperty` and its alias `data`.

```
$instance = new MyObject();
echo $instance->property.PHP_EOL; // GET-
$instance->property = 'something';
echo $instance->property.PHP_EOL; // GET-SET-something
echo $instance->getData().PHP_EOL; // DATA:hidden value
echo $instance->data.PHP_EOL; // DATA:hidden value
echo $instance->anyProperty.PHP_EOL; // throws error Property accessor "anyProperty" not found.
```

You can change behaviour of your property when `isset`/`unset` are used via `has*` and `remove*` methods.

```
class StringProperty extends \aw\Object {
    private $_property = '';
    public function getProperty():string {
        return $this->_property;
    }
    public function setProperty(string $value) {
        $this->_property = $value;
    }
    protected function hasProperty():bool {
        return (bool)$this->_property;
    }
    protected function removeProperty() {
        $this->_property = '';
    }
}
```

Then check if your property is empty or set it to be empty:

```
$prop = new StringProperty();
echo json_encode(isset($prop->property)).PHP_EOL; // false
$prop->property = 'value';
echo json_encode(isset($prop->property)).PHP_EOL; // true
unset($prop->property);
echo json_encode($prop->property).PHP_EOL; // "" -- will output empty string in JSON format
echo json_encode(isset($prop->property)).PHP_EOL; // false
```

*Note:* Defining `has*` and `remove*` methods is optional, but without them you will not be able to define logic for `isset()` and `unset()` actions over your property. Without them unset/delete property via `unset()` just tries to pass `null` into property mutator method and even if property set to `null`, `isset()` will always return `true`:

```
class MySimpleObject extends \aw\Object {
    private $_property = null;
    public function getProperty(){
        return $this->_property;
    }
    public function setProperty($value){
        $this->_property = $value;
    }
}

$simple = new MySimpleObject();
$simple->property = 'something';
echo 'Is set: '.json_encode(isset($simple->property)).PHP_EOL; // Is set: true
echo 'Is null: '.json_encode(is_null($simple->property)).PHP_EOL; // Is null: false
unset($simple->property);
echo 'Is set: '.json_encode(isset($simple->property)).PHP_EOL; // Is set: true
echo 'Is null: '.json_encode(is_null($simple->property)).PHP_EOL; // Is null: true
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

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

Total

3

Last Release

3783d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c10f33e471855407609160df895479e2f52f7d1e262ff56fccc8053322d47b5?d=identicon)[a\_\[w\]](/maintainers/a_[w])

---

Top Contributors

[![burdiuz](https://avatars.githubusercontent.com/u/255853?v=4)](https://github.com/burdiuz "burdiuz (35 commits)")

---

Tags

classobjectaccessormutatorgettersetterextend

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/actualwave-object/health.svg)

```
[![Health](https://phpackages.com/badges/actualwave-object/health.svg)](https://phpackages.com/packages/actualwave-object)
```

###  Alternatives

[yzen.dev/plain-to-class

Class-transformer to transform your dataset into a structured object

16293.9k6](/packages/yzendev-plain-to-class)[antares/accessible

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

123.9k1](/packages/antares-accessible)

PHPackages © 2026

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