2017 © Pedro Peláez
 

library delegate

image

aviator/delegate

  • Wednesday, October 11, 2017
  • by danielsdeboer
  • Repository
  • 1 Watchers
  • 0 Stars
  • 52 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 4 % Grown

The README.md

Build Status, (*1)

Overview

Delegate is a simple way to make property calls chainable when they otherwise wouldn't be., (*2)

Installation

Via Composer:, (*3)

composer require aviator/delegate

Testing

Via Composer:, (*4)

composer test

Usage

Use a magic __get to set up a delegate:, (*5)

public function __get ($name)
{
    if ($name === 'foo') {
        return $this->getFooDelegate()
    }
}

which will return the delegate when $instance->foo is called., (*6)

Since Delegate accepts anything as its first parameter and a Closure as its second, you can do anything:, (*7)

private function getFooDelegate ()
{
    return new Delegate($this->someMember, function ($collection, $name) {
        return $collection->get($name);
    }
}

This allows you to call $instance->foo->bar, which will call your function against someMember., (*8)

The Versions

11/10 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

11/10 2017

1.0

1.0.0.0

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires