This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Trait to add get-, set- and similar methods that simulate real class properties at runtime for rapid development.

v1.0.1 2020-07-19 16:23 UTC

This package is auto-updated.

Last update: 2021-07-19 18:54:59 UTC


Trait to add get-, set- and similar methods that simulate real class properties at runtime for rapid development.

Latest Stable Version Total Downloads Latest Unstable Version License


Install aether via composer:

composer require a6a/aether


Use the trait in any class to add get-, set-, unset-, merge-, and is- methods for accessing properties, flags, and lists. Replace the - with any upper camel case string.

require_once 'vendor/autoload.php';

use \A6A\Aether\Aether;

class A
  use Aether;

$a = new A();
$a->setNiceName('Cavendish Beach');

// later, somewhere else in the project ...

if($a->isOpen() && $a->hasNiceName()){
    <p>Vacation at <?= $a->getNiceName() ?> this season!</p>


Get or set a property with the get- and set- methods. Check if a property has been set with has-. Clean up with unset- or uns-.

// Getting a property that hasn't been set will return null.
$a->hasFoo(); // false
$a->getFoo(); // null

$a->hasFoo(); // true
$a->getFoo(); // 'foo'

$a->hasFoo(); // false

// shorthand unset-
$a->getFoo(); // null

// Chain multiple set- or unset- to do a few at once.

// Get the whole set of properties with get()
$a->get(); // array('one' => 1, 'two' => 2)

// Unset all properties with unset() or uns()
$a->get(); // array()


Set or check a boolean flag with the is- method.


// Any truthy or falsey value will do for setting but only true or false come out.
if(true === $a->isOpen()) ... // true

// Get the whole set of flags with is()
$this->is(); // array('apple' => true, 'fruit' => true, 'tasty' => true);


Merge multiple values together into a list of values with merge-.

$a->mergeMyList('point #1');
$a->mergeMyList('point #2');

$a->getMyList(); // array('point #1', 'point #2');

// A previously set property will be converted to a list if a merge- is done later.
$a->setSales(array('July 19' => 7));
$a->mergeSales(array('July 18' => 11));
$a->getSales(); // array(array('July 19' => 7), array('July 18' => 11));

// The merge- returns the full list after adding the new value
$formats = $a->mergeFormats('italic'); // array('bold', 'italic')


These methods provide a casual way to code to tests and implement functionality in the early stages of a project. Go from nothing to something fast! They are also handy for one-off coding to deadlines when delivering a single financial or operations report, and similar.

Each usage of these methods causes a few extra lookups and some unnecessary overhead in your code. Think carbon footprint. Before your code enters production at significant scale and after you have plenty of passing tests to make refactoring easy, replace these with concrete implementations and real properties to improve code quality and efficiency.


See the CHANGELOG file.


See the LICENSE file for license rights and limitations (MIT).