Passed
Pull Request — master (#283)
by Théo
02:08
created

MessageRenderer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 18
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A render() 0 28 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the box project.
7
 *
8
 * (c) Kevin Herrera <[email protected]>
9
 *     Théo Fidry <[email protected]>
10
 *
11
 * This source file is subject to the MIT license that is bundled
12
 * with this source code in the file LICENSE.
13
 */
14
15
namespace KevinGH\Box\Console;
16
17
use Symfony\Component\Console\Style\SymfonyStyle;
18
use function array_map;
19
20
/**
21
 * @private
22
 */
23
final class MessageRenderer
24
{
25
    public static function render(SymfonyStyle $io, array $recommendations, array $warnings): void
26
    {
27
        if ([] === $recommendations) {
28
            $io->writeln('No recommendation found.');
29
        } else {
30
            $io->writeln('Recommendations:');
31
32
            $io->writeln(
33
                array_map(
34
                    function (string $recommendation): string {
35
                        return "    - <recommendation>$recommendation</recommendation>";
36
                    },
37
                    $recommendations
38
                )
39
            );
40
        }
41
42
        if ([] === $warnings) {
43
            $io->writeln('No warning found.');
44
        } else {
45
            $io->writeln('Warnings:');
46
47
            $io->writeln(
48
                array_map(
49
                    function (string $warning): string {
50
                        return "    - <warning>$warning</warning>";
51
                    },
52
                    $warnings
53
                )
54
            );
55
        }
56
    }
57
58
    private function __construct()
59
    {
60
    }
61
}
62