PHPackages                             grottopress/setter - 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. grottopress/setter

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

grottopress/setter
==================

Set private object attributes directly, without calling setter methods.

v1.0.0(2y ago)016MITPHPPHP &gt;=7.0CI failing

Since Aug 5Pushed 2y ago1 watchersCompare

[ Source](https://github.com/GrottoPress/setter)[ Packagist](https://packagist.org/packages/grottopress/setter)[ RSS](/packages/grottopress-setter/feed)WikiDiscussions master Synced today

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

Setter
======

[](#setter)

Description
-----------

[](#description)

*Setter* allows you to set **private** object attributes directly, without calling setter methods.

For example, instead of calling `$myObject->setMyAttr($newValue)`, you can just do `$myObject->myAttr = $newValue`. Under the hood, *Setter* sets your attribute by calling a private `setMyAttr()` method that you define in your class.

This way, you get the benefit of syntactic sugar, while maintaining encapsulation.

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

[](#installation)

Install via composer:

```
composer require grottopress/setter
```

Usage
-----

[](#usage)

Import trait into your class, and use thus:

```
