denpamusic/php-levin

View on GitHub
src/Traits/InteractsWithConsole.php

Summary

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

declare(strict_types=1);

namespace Denpa\Levin\Traits;

use Denpa\Levin\Console;

trait InteractsWithConsole
{
    /**
     * @var \Denpa\Levin\Console
     */
    protected $console;

    /**
     * @param mixed $message
     * @param mixed $args,...
     *
     * @return \Denpa\Levin\Console
     */
    protected function console($message = '', ...$args): Console
    {
        if (!$this->console instanceof Console) {
            $this->console = new Console();
        }

        if ($message != '') {
            $this->console->line($message, ...$args);
        }

        return $this->console;
    }
}