mirror of
https://github.com/n3w/helpers-cli-input.git
synced 2025-12-19 20:53:27 +00:00
Initial commit
This commit is contained in:
commit
0620d00f08
24 changed files with 1054 additions and 0 deletions
13
src/Input/Exceptions/InputNotFoundException.php
Normal file
13
src/Input/Exceptions/InputNotFoundException.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pointybeard\Helpers\Cli\Input\Exceptions;
|
||||
|
||||
class InputHandlerNotFoundException extends \Exception
|
||||
{
|
||||
public function __construct(string $handler, string $command, $code = 0, \Exception $previous = null)
|
||||
{
|
||||
return parent::__construct(sprintf('The input handler %s could not be located.', $handler), $code, $previous);
|
||||
}
|
||||
}
|
||||
22
src/Input/Exceptions/RequiredArgumentMissingException.php
Normal file
22
src/Input/Exceptions/RequiredArgumentMissingException.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pointybeard\Helpers\Cli\Input\Exceptions;
|
||||
|
||||
class RequiredArgumentMissingException extends \Exception
|
||||
{
|
||||
private $argument;
|
||||
|
||||
public function __construct(string $argument, $code = 0, \Exception $previous = null)
|
||||
{
|
||||
$this->argument = strtoupper($argument);
|
||||
|
||||
return parent::__construct("missing argument {$this->argument}.", $code, $previous);
|
||||
}
|
||||
|
||||
public function getArgumentName(): string
|
||||
{
|
||||
return $this->argument;
|
||||
}
|
||||
}
|
||||
29
src/Input/Exceptions/RequiredInputMissingException.php
Normal file
29
src/Input/Exceptions/RequiredInputMissingException.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pointybeard\Helpers\Cli\Input\Exceptions;
|
||||
|
||||
use pointybeard\Helpers\Cli\Input;
|
||||
|
||||
class RequiredInputMissingException extends \Exception
|
||||
{
|
||||
private $input;
|
||||
|
||||
public function __construct(Input\AbstractInputType $input, $code = 0, \Exception $previous = null)
|
||||
{
|
||||
$this->input = $input;
|
||||
|
||||
return parent::__construct(sprintf(
|
||||
'missing %s %s%s',
|
||||
$input->getType(),
|
||||
'option' == $input->getType() ? '-' : '',
|
||||
'option' == $input->getType() ? $input->name() : strtoupper($input->name())
|
||||
), $code, $previous);
|
||||
}
|
||||
|
||||
public function getInput(): Input\AbstractInputType
|
||||
{
|
||||
return $this->input;
|
||||
}
|
||||
}
|
||||
29
src/Input/Exceptions/RequiredInputMissingValueException.php
Normal file
29
src/Input/Exceptions/RequiredInputMissingValueException.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pointybeard\Helpers\Cli\Input\Exceptions;
|
||||
|
||||
use pointybeard\Helpers\Cli\Input;
|
||||
|
||||
class RequiredInputMissingValueException extends \Exception
|
||||
{
|
||||
private $input;
|
||||
|
||||
public function __construct(Input\AbstractInputType $input, $code = 0, \Exception $previous = null)
|
||||
{
|
||||
$this->input = $input;
|
||||
|
||||
return parent::__construct(sprintf(
|
||||
'%s %s%s is missing a value',
|
||||
$input->getType(),
|
||||
'option' == $input->getType() ? '-' : '',
|
||||
'option' == $input->getType() ? $input->name() : strtoupper($input->name())
|
||||
), $code, $previous);
|
||||
}
|
||||
|
||||
public function getInput(): Input\AbstractInputType
|
||||
{
|
||||
return $this->input;
|
||||
}
|
||||
}
|
||||
13
src/Input/Exceptions/UnableToLoadInputHandlerException.php
Normal file
13
src/Input/Exceptions/UnableToLoadInputHandlerException.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pointybeard\Helpers\Cli\Input\Exceptions;
|
||||
|
||||
class UnableToLoadInputHandlerException extends \Exception
|
||||
{
|
||||
public function __construct(string $name, $code = 0, \Exception $previous = null)
|
||||
{
|
||||
return parent::__construct(sprintf('The input handler %s could not be loaded. Returned: %s', $name, $previous->getMessage()), $code, $previous);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue