PHPackages                             slaxweb/getset - 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. slaxweb/getset

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

slaxweb/getset
==============

Getter and Setter traits for SlaxWeb Framework

0.1.0(9y ago)0930[1 issues](https://github.com/SlaxWeb/GetSet/issues)3MITPHPPHP &gt;=7.0.0

Since Jan 10Pushed 9y ago3 watchersCompare

[ Source](https://github.com/SlaxWeb/GetSet)[ Packagist](https://packagist.org/packages/slaxweb/getset)[ RSS](/packages/slaxweb-getset/feed)WikiDiscussions master Synced today

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

GetSet
======

[](#getset)

GetSet component provides the **MagicGet** and **MagicSet** traits that can be used to simplify and unify implementation of magic getter and setter.

Installation
------------

[](#installation)

Installation can be done through [composer](https://getcomposer.org), just add **slaxweb/getset** package to your *composer.json* file:

```
{
    "require": {
        "slaxweb/getset": "0.1.*@dev"
    }
}
```

Usage
-----

[](#usage)

Usage of **MagicGet** and **MagicSet** traits is pretty simple and straightforward, you just need to **use** them in your class, and writing and reading of your otherwise inaccessible properties is available. Both the **MagicGet** and **MagicSet** traits will prepend an underscore *(\_)* to the name of the requested property. If you wish to alter or disable the prepend, then your class that uses those traits must define the **\_getSetPrepend**property with the value you wish to prepend to the requested properties.

If the requested property does not exist, then both traits will throw the **\\SlaxWeb\\Exception\\UnknownPropertyException** exception.

Example usage:

```
