2017 © Pedro Peláez
 

library fluent-interface

Turns methods of any non-final class that do not return anything into chainable, fluent interfaces.

image

badcow/fluent-interface

Turns methods of any non-final class that do not return anything into chainable, fluent interfaces.

  • Monday, April 6, 2015
  • by samuelwilliams
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Badcow Fluent Interface

Turns methods of any non-final class that do not return anything into chainable, fluent interfaces., (*1)

Disclaimer

This is a joke. I made this library after an argument with the senior dev who doesn't like fluent interfaces. If you can think of a legitimate use for this library, I would like to know., (*2)

Installation

Using composer

//composer.json
{
    "require": {
        "badcow/fluent-interface": "dev-master"
    }
}

Basic Usage

Non fluent class

<?php
//sample_class.php

namespace Sour\Milk;

class FooBar
{
    /**
     * @var string
     */
    private $firstName;

    /**
     * @var string
     */
    private $lastName;

    /**
     * @return string
     */
    public function getFirstName()
    {
        return $this->firstName;
    }

    /**
     * @return string
     */
    public function getLastName()
    {
        return $this->lastName;
    }

    /**
     * @param string $firstName
     */
    public function setFirstName($firstName)
    {
        $this->firstName = $firstName;
    }

    /**
     * @param string $lastName
     */
    public function setLastName($lastName)
    {
        $this->lastName = $lastName;
    }
}

Create fluent proxy

<?php

use Badcow\FluentInterface\FluentInterface;

//Set the directory where to store the proxy classes
$fi = new FluentInterface(__DIR__ . '/Proxies');

//Create a proxy class. The second parameter forces the recreation of the file.
$proxy = $fi->create('Sour\Milk\Foobar', true);
$foobar = new $proxy();

//Class is now a fluent interface
$foobar->setFirstName('Sam')->setLastName('Williams');

echo $foobar->getFirstName() . ' ' . $foobar->getLastName();

Running the test suite

The test suite is run using PHPUnit., (*3)

$ cd /path/to/badcow-fluent/interface/
$ composer install
$ phpunit .

Build Status

Build Status, (*4)

The Versions

06/04 2015

dev-master

9999999-dev

Turns methods of any non-final class that do not return anything into chainable, fluent interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

by Sam Williams

06/04 2015

v1.0.0

1.0.0.0

Turns methods of any non-final class that do not return anything into chainable, fluent interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

by Sam Williams

11/03 2013

v0.1

0.1.0.0

Turns methods of any non-final class that do not return anything into chainable, fluent interfaces.

  Sources   Download

MIT

The Development Requires

by Sam Williams