2017 © Pedro Peláez
 

library makeable

Static constructor trait and interface.

image

aviator/makeable

Static constructor trait and interface.

  • Thursday, November 30, 2017
  • by danielsdeboer
  • Repository
  • 1 Watchers
  • 0 Stars
  • 206 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

Build Status Latest Stable Version License, (*1)

Overview

This package provides a static constructor interface, and a trait that implements the interface., (*2)

Installation

Via Composer:, (*3)

composer require aviator/makeable

Testing

Via Composer:, (*4)

composer test

Usage

Use the trait:, (*5)

class Something
{
    use MakeableTrait;
}

Then the class can be instantiated using Class::make(...$args):, (*6)

$instance = Something::make($arg1, $arg2);

The interface is optional, though it can be useful in composite interfaces to specify that a static constructor should be present:, (*7)

interface SomeInterface extends Makeable, SomeOtherInterface
{
    /* ... etc */
}

Since the static constructor simply returns new static(...$args), it can be used in abstract classes and parent classes without having to re-use it on child classes:, (*8)

abstract class Seuss
{
    use MakeableTrait;
}

class ThingOne extends Seuss {};
class ThingTwo extends ThingOne {};

// Get an instance of ThingOne
$instance = ThingOne::make();

// Get an instance of ThingTwo
$instance = ThingTwo::make();

Other

License

This package is licensed with the MIT License (MIT)., (*9)

The Versions

30/11 2017

dev-master

9999999-dev https://github.com/danielsdeboer/makeable

Static constructor trait and interface.

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

php static php7 constructor

30/11 2017

0.1.0

0.1.0.0 https://github.com/danielsdeboer/makeable

Static constructor trait and interface.

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

php static php7 constructor