Skip to content

Commit

Permalink
Invoker and Constructor interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
dakujem committed Jul 8, 2020
1 parent 846e136 commit a1bcda5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Constructor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Dakujem;

/**
* A general interface for an object able to create instances of other classes.
* These implementations will usually provide arguments to the constructor call.
*
* @author Andrej Rypák (dakujem) <[email protected]>
*/
interface Constructor
{
/**
* Creates an instance of a class.
*
* @param string $target class name of a class to be instantiated
* @return mixed an instance of the target class
*/
public function construct(string $target);
}
24 changes: 24 additions & 0 deletions src/Invoker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Dakujem;

/**
* A general interface for an object able to invoke callables.
* These implementations will usually provide arguments to the call.
*
* @author Andrej Rypák (dakujem) <[email protected]>
*/
interface Invoker
{
/**
* Invokes a callable.
* Returns the result of the call.
* Arguments provided to the call differ according to implementation.
*
* @param callable $target callable to be invoked
* @return mixed result of the $target callable invocation
*/
public function invoke(callable $target);
}

0 comments on commit a1bcda5

Please sign in to comment.