Passed
Push — master ( a05e52...524499 )
by Caen
03:18 queued 12s
created

Command::inlineGray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Console\Concerns;
6
7
use Hyde\Hyde;
8
use LaravelZero\Framework\Commands\Command as BaseCommand;
9
10
/**
11
 * @see \Hyde\Framework\Testing\Feature\CommandTest
12
 */
13
abstract class Command extends BaseCommand
14
{
15
    /**
16
     * Create a filepath that can be opened in the browser from a terminal.
17
     */
18
    public static function createClickableFilepath(string $filepath): string
19
    {
20
        return 'file://'.str_replace('\\', '/', realpath($filepath) ?: Hyde::path($filepath));
21
    }
22
23
    /**
24
     * Write a nicely formatted and consistent message to the console. Using InfoComment for a lack of a better term.
25
     */
26
    public function infoComment(string $info, string $comment, ?string $moreInfo = null): void
27
    {
28
        $this->line("<info>$info</info> [<comment>$comment</comment>]".($moreInfo ? " <info>$moreInfo</info>" : ''));
29
    }
30
31
    /** @experimental This method may change (or be removed) before the 1.0.0 release */
32
    public function gray(string $string): void
33
    {
34
        $this->line($this->inlineGray($string));
35
    }
36
37
    /** @experimental This method may change (or be removed) before the 1.0.0 release */
38
    public function inlineGray(string $string): string
39
    {
40
        return "<fg=gray>$string</>";
41
    }
42
43
    public function indentedLine(int $indent, string $string): void
44
    {
45
        $this->line(str_repeat(' ', $indent).$string);
46
    }
47
}
48