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

ActiveLibrary

grottopress/getter
==================

Get private object attributes directly, without calling getter methods.

v1.0.0(2y ago)02.0k4MITPHPPHP &gt;=7.0CI failing

Since Aug 5Pushed 2y ago1 watchersCompare

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

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

Getter
======

[](#getter)

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

[](#description)

*Getter* allows you to get **private** object attributes directly, without calling getter methods.

For example, instead of calling `$myObject->getMyAttr()`, you can just do `$myObject->myAttr`. Under the hood, *Getter* gets your attribute by calling a private `getMyAttr()` 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/getter`

Usage
-----

[](#usage)

Import trait into your class, and use thus:

```
