PHPackages                             peridot-php/peridot-scope - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. peridot-php/peridot-scope

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

peridot-php/peridot-scope
=========================

Scopes for function binding and mixins

1.3.0(10y ago)1226.4k↓24.4%12MITPHPPHP &gt;=5.4.0

Since Nov 14Pushed 9y ago3 watchersCompare

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

READMEChangelogDependencies (1)Versions (5)Used By (2)

Peridot Scope
=============

[](#peridot-scope)

[![Build Status](https://camo.githubusercontent.com/fa30b813ff0f0a14f864e9aa064329b4b334ec0ff5fb0adbae13a0fbe891b15f/68747470733a2f2f7472617669732d63692e6f72672f70657269646f742d7068702f70657269646f742d73636f70652e706e67)](https://travis-ci.org/peridot-php/peridot-scope) [![HHVM Status](https://camo.githubusercontent.com/6a94e90f901d06590078e9d999c5b6f093275544d2550e00ae134f2e99f66a99/687474703a2f2f6868766d2e683463632e64652f62616467652f70657269646f742d7068702f70657269646f742d73636f70652e737667)](http://hhvm.h4cc.de/package/peridot-php/peridot-scope)

Peridot [Scope](https://github.com/peridot-php/peridot/wiki/Scopes).

Scopes allow safe binding of state for closures and offers a mechanism for mixing state and behavior in via [child scopes](https://github.com/peridot-php/peridot/wiki/Scopes#extending-functionality-with-scopes).

Extracted from the [Peridot](http://peridot-php.github.io/) testing framework.

\##Usage

We recommend installing this package via composer:

```
$ composer require peridot-php/peridot-scope:~1.0

```

\###Creating a Scope

```
$scope = new Scope();
$scope->name = "Brian";

$fnWithName = function() {
    print $this->name;
};

$fnWithName = $scope->peridotBindTo($fnWithName);

$fnWithName(); //prints "Brian"
```

\###Using the ScopeTrait

If an existing class can benefit from a Scope, you can use the `ScopeTrait`

```
class Test
{
    use ScopeTrait;

    protected $definition;

    public function __construct(callable $definition)
    {
        $this->definition = $definition;
    }

    /**
     * Return the definition bound to a scope
     */
    public function getDefinition()
    {
        $scope = $this->getScope();
        return $scope->peridotBindTo($this->definition);
    }
}
```

\##Mixins

You can mix behavior in via [child scopes](https://github.com/peridot-php/peridot/wiki/Scopes#extending-functionality-with-scopes).

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~155 days

Total

4

Last Release

3738d ago

### Community

Maintainers

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

---

Top Contributors

[![brianium](https://avatars.githubusercontent.com/u/636651?v=4)](https://github.com/brianium "brianium (12 commits)")[![ezzatron](https://avatars.githubusercontent.com/u/100152?v=4)](https://github.com/ezzatron "ezzatron (3 commits)")

### Embed Badge

![Health badge](/badges/peridot-php-peridot-scope/health.svg)

```
[![Health](https://phpackages.com/badges/peridot-php-peridot-scope/health.svg)](https://phpackages.com/packages/peridot-php-peridot-scope)
```

PHPackages © 2026

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