2017 © Pedro Peláez
 

library nsa

See everything and do whatever you want. No privacy rule will stop us. Used in tests, debugging and fixtures to access properties and methods.

image

nyholm/nsa

See everything and do whatever you want. No privacy rule will stop us. Used in tests, debugging and fixtures to access properties and methods.

  • Monday, March 26, 2018
  • by Nyholm
  • Repository
  • 7 Watchers
  • 89 Stars
  • 124,952 Installations
  • PHP
  • 29 Dependents
  • 1 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 38 % Grown

The README.md

NSA; See and do whatever you want. Great for writing tests

Latest Version Software License Build Status Code Coverage Quality Score Total Downloads, (*1)

This small class helps you to test your private and protected properties and methods. One could argue that you never should test private methods but sometimes it just makes the test code a lot cleaner and easier to write and understand. This library is all about DX., (*2)

Usage

$object = new Dog();

NSA::setProperty($object, 'name', 'Foobar');
$name = NSA::getProperty($object, 'name');
$result = NSA::invokeMethod($object, 'doAction', 'jump', '1 meter');

echo $name; // "Foobar"
echo $result; // "Dog just did 'jump' for 1 meter"

// Access static properties and methods
$age = NSA::getProperty('\Dog', 'age');
echo $age; // 12
class Dog
{
    private $name = 'unnamed';
    private static $age = 12;

    private function doAction($action, $parameter)
    {
        return sprintf("Dog just did '%s' for %s", $action, $parameter);
    }
}

Install

bash $ composer require nyholm/nsa, (*3)

License

The MIT License (MIT). Please see License File for more information., (*4)

The Versions

26/03 2018

dev-master

9999999-dev http://tnyholm.se

See everything and do whatever you want. No privacy rule will stop us. Used in tests, debugging and fixtures to access properties and methods.

  Sources   Download

MIT

The Requires

 

The Development Requires

debug test reflection fixture

13/04 2017

1.1.0

1.1.0.0 http://tnyholm.se

See everything and do whatever you want. No privacy rule will stop us. Used in tests, debugging and fixtures to access properties and methods.

  Sources   Download

MIT

The Requires

 

The Development Requires

debug test reflection fixture

09/08 2016

1.0.1

1.0.1.0 http://tnyholm.se

See everything and do whatever you want. No privacy rule will stop us. Used in tests, debugging and fixtures to access properties and methods.

  Sources   Download

MIT

The Requires

 

The Development Requires

debug test reflection fixture

06/08 2016

1.0.0

1.0.0.0 http://tnyholm.se

See everything and do whatever you want. No privacy rule will stop us. Used in tests, debugging and fixtures to access properties and methods.

  Sources   Download

MIT

The Requires

 

The Development Requires

debug test reflection fixture