honeybadger-io/honeybadger-laravel

View on GitHub
src/Concerns/RequiredInput.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace Honeybadger\HoneybadgerLaravel\Concerns;

trait RequiredInput
{
    /**
     * Prompts for a required secret until its given.
     *
     * @param  string  $question
     * @param  string  $failedMessage
     * @return string
     */
    public function requiredSecret($question, $failedMessage)
    {
        $input = $this->secret($question);

        if (is_null($input)) {
            $this->error($failedMessage);

            return $this->requiredSecret($question, $failedMessage);
        }

        return $input;
    }

    abstract public function secret($message, $fallback = true);

    abstract public function error($message, $verbosity = null);
}