Link Search Menu Expand Document

Usage

Table of contents

  1. Using Inheritance
  2. Using Composition

There are different ways of using this package which will be outlined further down. Choose whatever suits your needs better.

Using Inheritance

The most simple way to use the package is by extending the CreatableObject class:

use NorseBlue\CreatableObjects\CreatableObject;

class MyObject extends CreatableObject
{
    private function __construct() { }
}

See complete example

Using Composition

If you prefer composition over inheritance, you can use the provided trait and interface instead:

use NorseBlue\CreatableObjects\Contracts\Creatable;
use NorseBlue\CreatableObjects\Traits\HandlesObjectCreation;

class MyObject implements Creatable
{
    use HandlesObjectCreation;
    
    private function __construct() { }
}

See complete example