Link Search Menu Expand Document

Examples

Table of contents

  1. Defining a Facade
  2. Defining a facade with skipped constructor parameters

Defining a Facade

<?php

declare(strict_type=1);

namespace NorseBlue\ObjectFacades\Examples;

use NorseBlue\ObjectFacades\Facade;

class MyObject
{
    private $value;

    public function __construct(int $value)
    {
        $this->value = $value;
    }

    public function add(int $operand): int
    {
        return $this->value + $operand;
    }
}

/**
 * @method static int add(int $value, int $operand)
 */
class MyObjectFacade extends Facade
{
    protected static $target_class = MyObject::class;
}

Defining a facade with skipped constructor parameters

<?php

declare(strict_type=1);

namespace NorseBlue\ObjectFacades\Examples;

use NorseBlue\ObjectFacades\Facade;

class MyObject
{
    private $value;

    public function __construct(int $value)
    {
        $this->value = $value;
    }

    public function add(int $operand): int
    {
        return $this->value + $operand;
    }
}

/**
 * @method static int add(int $value, int $operand)
 */
class MyObjectFacade extends Facade
{
    protected static $target_class = MyObject::class;
}