richtoms/spot

Simple PHP Object Tracker

v0.1 2021-02-22 04:56 UTC

This package is auto-updated.

Last update: 2024-09-22 12:30:03 UTC


README

Latest Version on Packagist Build Status Total Downloads

SPOT is a small library designed to track timing and memory usage of your PHP functions and class methods.

Installation

You can install the package via composer:

composer require richtoms/spot

Usage

Using the class tracker for a class.

use RichToms\Spot\ClassTracker;

$tracker = new ClassTracker(new Foo('Bar'));
$tracker->methodOnFoo()
    ->anotherMethod()
    ->andAnother();

// Result of fluently calling methods on the `Foo` class.
$result = $tracker->getResult();

// List of events tracked while calling many methods on the `Foo` class.
$events = $tracker->getEvents();

Using the closure tracker.

$tracker = new ClosureTracker(function ($array) {
    return array_map(function ($item) {
        return $x += 1;
    }, $array);
}, [[1, 2, 3, 4]]);

// Result of the Closure.
$result = $tracker->getResult();

// List of events tracked when calling the Closure.
$result->getEvents();

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email richard.toms@hotmail.com instead of using the issue tracker.

Credits

License

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