Passed
Push — master ( 486f33...203560 )
by Caen
03:17 queued 13s
created

Command::createClickableFilepath()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
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