2017 © Pedro Peláez
 

library peridot-scope

Scopes for function binding and mixins

image

peridot-php/peridot-scope

Scopes for function binding and mixins

  • Sunday, July 31, 2016
  • by brianium
  • Repository
  • 3 Watchers
  • 1 Stars
  • 98,303 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 5 Versions
  • 5 % Grown

The README.md

Peridot Scope

Build Status HHVM Status, (*1)

Peridot Scope., (*2)

Scopes allow safe binding of state for closures and offers a mechanism for mixing state and behavior in via child scopes., (*3)

Extracted from the Peridot testing framework., (*4)

Usage

We recommend installing this package via composer:, (*5)

$ 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, (*6)

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., (*7)

The Versions

31/07 2016

dev-master

9999999-dev

Scopes for function binding and mixins

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

22/02 2016

1.3.0

1.3.0.0

Scopes for function binding and mixins

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

15/04 2015

1.2.0

1.2.0.0

Scopes for function binding and mixins

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

16/11 2014

1.1.0

1.1.0.0

Scopes for function binding and mixins

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

14/11 2014

1.0.0

1.0.0.0

Scopes for function binding and mixins

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires