PHPackages                             thrashzone13/visitor - 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. thrashzone13/visitor

ActiveLibrary

thrashzone13/visitor
====================

Simple implementation of visitor design pattern

V1.0.1(1y ago)238MITPHPPHP ^7.2|^8.0

Since Jul 31Pushed 1y ago1 watchersCompare

[ Source](https://github.com/thrashzone13/visitor)[ Packagist](https://packagist.org/packages/thrashzone13/visitor)[ Docs](https://github.com/thrashzone13/visitor)[ RSS](/packages/thrashzone13-visitor/feed)WikiDiscussions master Synced today

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

visitor
=======

[](#visitor)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4646450ca2aa4aa460e82091dc6f093cd60c13efc4ed7f575373895a24d70190/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7468726173687a6f6e6531332f76697369746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thrashzone13/visitor)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/1adcd9654d8b5b576fec3694c6a17ab35e38fd2b0b388ba00ac37f30719c8c1c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7468726173687a6f6e6531332f76697369746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thrashzone13/visitor)

This package provides a visitor pattern implementation.

Visitor Pattern
---------------

[](#visitor-pattern)

Visitor is a behavioral design pattern that lets you separate algorithms from the objects on which they operate.

Install
-------

[](#install)

Via Composer

```
$ composer require thrashzone13/visitor
```

Usage
-----

[](#usage)

Consider having an array of different kinds of shapes

```
$shapes = [
    new Circle(radius: 10),
    new Rectangle(width: 15, height: 20),
    new Rectangle(width: 10, height: 14),
    new Square(side: 16)
];
```

Let's say the intention is to calculate their area and sum them up. There can be a visitor which does the calculation regarding the type of the received instance

```
$visitor = (new Visitor)
    ->add(fn(Circle $circle) => pi() * $circle->getRadius() * $circle->getRadius())
    ->add(fn(Square $square) => $square->getSide() * $square->getSide())
    ->add(fn(Rectangle $rectangle) => $rectangle->getWidth() * $rectangle->getHeight());
```

Now it's ready to use!

```
$totalArea = 0;
foreach ($shapes as $shape) {
    $totalArea += $visitor->visit($shape);
}
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 63% of packages

Maintenance43

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

Every ~144 days

Total

2

Last Release

454d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f36d7d47f75adcf7818460823045de0ad0a34c2f67d3fdf1d0a413ae6021bf6?d=identicon)[thrashzone13](/maintainers/thrashzone13)

---

Top Contributors

[![thrashzone13](https://avatars.githubusercontent.com/u/50789773?v=4)](https://github.com/thrashzone13 "thrashzone13 (19 commits)")

---

Tags

visitorthrashzone13

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/thrashzone13-visitor/health.svg)

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

###  Alternatives

[pragmarx/tracker

A Laravel Visitor Tracker

3.0k298.5k1](/packages/pragmarx-tracker)[shetabit/visitor

Laravel visitor

563553.2k7](/packages/shetabit-visitor)[sarfraznawaz2005/visitlog

Laravel package to log visitor information into database.

9015.8k](/packages/sarfraznawaz2005-visitlog)

PHPackages © 2026

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