11
0
Fork 0
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:
Alannah Kearney 2019-05-20 15:08:41 +10:00
commit 0620d00f08
24 changed files with 1054 additions and 0 deletions

View 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);
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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);
}
}