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

Command   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 3
c 3
b 0
f 0
dl 0
loc 16
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createClickableFilepath() 0 3 2
A infoComment() 0 3 2
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