-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from minicli/input-layer-initial
Input Layer - Initial Implementation
- Loading branch information
Showing
14 changed files
with
284 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Minicli\Framework\Commands; | ||
|
||
use Minicli\Framework\Contracts\Commands\CommandContract; | ||
use Minicli\Framework\Exceptions\MissingParametersException; | ||
use Minicli\Framework\Input\Input; | ||
|
||
abstract class AbstractCommand implements CommandContract | ||
{ | ||
/** | ||
* @throws MissingParametersException | ||
*/ | ||
public function boot(Input $input): void | ||
{ | ||
$missing = array_diff($this->required(), array_keys($input->params())); | ||
|
||
if ([] !== $missing) { | ||
throw new MissingParametersException($missing); | ||
} | ||
} | ||
|
||
/** | ||
* @return array<int,string> | ||
*/ | ||
public function required(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function teardown(): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Minicli\Framework\Contracts\Commands; | ||
|
||
use Minicli\Framework\Input\Input; | ||
|
||
interface CommandContract | ||
{ | ||
/** | ||
* Executes the command logic. | ||
*/ | ||
public function handle(Input $input): void; | ||
|
||
/** | ||
* The list of parameters required by the command. | ||
* | ||
* @return array<int,string> | ||
*/ | ||
public function required(): array; | ||
|
||
/** | ||
* Called after the command is executed successfully. | ||
*/ | ||
public function teardown(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,4 @@ | |
|
||
interface MiniEnum | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,4 @@ | |
|
||
final class BindingResolutionException extends Exception | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,4 @@ | |
|
||
final class MinicliNamingException extends InvalidArgumentException | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Minicli\Framework\Exceptions; | ||
|
||
use Exception; | ||
|
||
final class MissingParametersException extends Exception | ||
{ | ||
public function __construct(array $missing) | ||
{ | ||
parent::__construct(sprintf( | ||
'Missing required parameters: %s', | ||
implode(', ', $missing) | ||
)); | ||
} | ||
} |
Oops, something went wrong.