Passed
Push — master ( 956163...dedbc7 )
by Christian
03:02
created

CocotteStyle   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 65
rs 10
c 0
b 0
f 0
wmc 11

11 Methods

Rating   Name   Duplication   Size   Complexity  
A pause() 0 3 1
A quittableQuestion() 0 3 1
A help() 0 3 1
A link() 0 3 1
A veryVerbose() 0 3 1
A optionHelp() 0 3 1
A debug() 0 3 1
A hostnameHelp() 0 11 1
A ok() 0 3 1
A complete() 0 3 1
A verbose() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Cocotte\Console;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
use Symfony\Component\Console\Style\SymfonyStyle;
7
8
final class CocotteStyle extends SymfonyStyle implements Style
9
{
10
11
    public function ok($message)
12
    {
13
        $this->block($message, 'OK', null, ' ', true);
14
    }
15
16
    public function help($message)
17
    {
18
        $this->block($message, 'HELP', null, ' ', false, false);
19
    }
20
21
    public function complete($messages): void
22
    {
23
        $this->block($messages, 'COMPLETE', 'fg=black;bg=green', ' ', true, false);
24
    }
25
26
    public function pause()
27
    {
28
        return $this->ask($this->quittableQuestion("Press <options=bold>ENTER</> to continue"));
29
    }
30
31
    public function optionHelp(string $title, array $message): string
32
    {
33
        return "<options=bold,underscore>{$title}</>"."\n".implode("\n", $message)."\n";
34
    }
35
36
    public function quittableQuestion($message): string
37
    {
38
        return "$message or press CTRL+D to quit";
39
    }
40
41
    public function link(string $url): string
42
    {
43
        return "<info>$url</info> \u{1F517} ";
44
    }
45
46
    public function hostnameHelp(string $name, string $subdomain): array
47
    {
48
        return [
49
            "This the fully qualified domain name for your $name.",
50
            "It has to be with a subdomain like in '<info>$subdomain.mydomain.com</info>', in which case\n".
51
            "'<info>mydomain.com</info>' must point to the name servers of Digital Ocean, and Cocotte\n".
52
            "will create and configure the '<info>$subdomain</info>' subdomain for you.",
53
            "Cocotte validates that the name servers of the domain you enter are Digital \nOcean's. ".
54
            "How to point to Digital Ocean name servers: ".$this->link('https://goo.gl/SJnw2c')."\n".
55
            "Please note that when a domain is newly registered, or the name servers are \nchanged, you can expect ".
56
            "a propagation time up to 24 hours.",
57
        ];
58
    }
59
60
    public function verbose($messages): void
61
    {
62
        $this->writeln($messages, OutputInterface::VERBOSITY_VERBOSE);
63
    }
64
65
    public function veryVerbose($messages): void
66
    {
67
        $this->writeln($messages, OutputInterface::VERBOSITY_VERY_VERBOSE);
68
    }
69
70
    public function debug($messages): void
71
    {
72
        $this->writeln($messages, OutputInterface::VERBOSITY_DEBUG);
73
    }
74
}