Skip to content

Latest commit

 

History

History
41 lines (31 loc) · 696 Bytes

InvokableTrait.md

File metadata and controls

41 lines (31 loc) · 696 Bytes

Docs / Integer / InvokableTrait

Allows get and set by invoke call.

Trait synopsis

trait InvokableTrait
{
    use TypeTrait;

    /**
     * Getter/setter implementation.
     * @param  int ...$args Input data.
     * @return int Current value.
     * @throws ArgumentCountError If called with too many arguments.
     */
    public function __invoke(int ...$args): int;
}

Examples

use Phrity\O\Integer\InvokableTrait;

class MyClass
{
    use InvokableTrait;

    public function __construct(int $input)
    {
        $this->initialize($input);
    }
}

$class = new MyClass(123);
$class(); // => 123
$class(456); // => 456