PHPackages                             konsulting/exposer - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. konsulting/exposer

ActiveLibrary[Testing &amp; Quality](/categories/testing)

konsulting/exposer
==================

0.1.0(8y ago)084MITPHP

Since Mar 5Pushed 7y ago2 watchersCompare

[ Source](https://github.com/konsulting/exposer)[ Packagist](https://packagist.org/packages/konsulting/exposer)[ RSS](/packages/konsulting-exposer/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Exposer
=======

[](#exposer)

Although for the most part only public methods of classes are unit tested, it's sometimes necessary or helpful to have access to protected or private methods and properties. Exposer provides a convenient way to do this whilst keeping your tests clear and concise.

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

[](#installation)

Install via Composer:

```
 $ composer require konsulting/exposer

```

Usage
-----

[](#usage)

Consider the following class:

```
class ClassUnderTest
{
    protected $secret = 'My secret';

    protected static $anotherSecret = 'My static secret';

    protected function add($number1, $number2)
    {
        return $number1 + $number2;
    }

    protected static function multiply($number1, $number2)
    {
        return $number1 * $number2;
    }
}
```

There are multiple ways to test the protected methods and properties on this class.

### Base Exposer

[](#base-exposer)

The most direct way is with the `BaseExposer` class. The subject must be passed into each method, and may be either an instance or the (string) class name.

```
use Konsulting\Exposer\BaseExposer;

// With an instance
BaseExposer::hasMethod(new ClassUnderTest, 'add');                          // true
BaseExposer::invokeMethod(new ClassUnderTest, 'add', [1, 1]);               // 2
BaseExposer::getProperty(new ClassUnderTest, 'secret');                     // 'My secret'

// Static context
BaseExposer::hasMethod(ClassUnderTest::class, 'multiply');                  // true
BaseExposer::invokeMethod(ClassUnderTest::class, 'multiply', [2,2]);        // 4
BaseExposer::getProperty(ClassUnderTest::class, 'anotherSecret');           // 'My static secret'
```

### Exposer

[](#exposer-1)

The `Exposer` class allows the use of a class's inaccessible methods and properties as if they were public.

```
use Konsulting\Exposer\Exposer;

$exposer = Exposer::make(new ClassUnderTest);

$exposer->add(1, 1);                                // 2
$exposer->multiply(2, 2);                           // 4
$exposer->secret;                                   // 'My secret'
$exposer->anotherSecret;                            // 'My static secret'

// These non-magic methods are also available
$exposer->invokeMethod('add', [1, 1]);               // 2
$exposer->getProperty('secret');                     // 'My secret'
```

Exposer can also access class's static methods and properties without the need to provide an instance.

```
use Konsulting\Exposer\Exposer;

$exposer = Exposer::make(ClassUnderTest::class);

$exposer->multiply(2, 2);                           // 4
$exposer->anotherSecret;                            // 'My static secret'

$exposer->invokeMethod('multiply', [2, 2]);         // 4
$exposer->getProperty('anotherSecret');             // 'My static secret'
```

**Note:** Static methods and properties are available from an instance context, but of course non-static methods and properties are not available from a static context.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

2991d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bae802ba5a70c050135022ed88fc558d2ac76ace8e5b67ce176f683d1a0afc1b?d=identicon)[rdarcy1](/maintainers/rdarcy1)

---

Top Contributors

[![rdarcy1](https://avatars.githubusercontent.com/u/15962421?v=4)](https://github.com/rdarcy1 "rdarcy1 (17 commits)")

---

Tags

phpreflectiontestingunit-testing

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/konsulting-exposer/health.svg)

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

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)

PHPackages © 2026

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