Completed
Push — master ( 097db7...6a86d4 )
by Bill
9s
created

TableBuilder::outputTable()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 8.6737
c 0
b 0
f 0
cc 5
eloc 12
nc 4
nop 2
1
<?php
2
3
namespace Bmitch\Envsync\Builders;
4
5
use Symfony\Component\Console\Helper\Table;
6
use Symfony\Component\Console\Output\ConsoleOutput;
7
8
class TableBuilder
9
{
10
    /**
11
     * Takes the provided $data and outputs a table on the console output.
12
     * @param  array  $data Enviroment variable results data.
13
     * @param  string $mode Mode the program is being run in.
14
     * @return void
15
     */
16
    public function outputTable(array $data, $mode)
17
    {
18
        $headers = ['Variable', 'In Source', 'In .env.example', 'In .env'];
19
20
        if ($mode == 'ci') {
21
            $headers = ['Variable', 'In Source', 'In .env.example'];
22
            foreach ($data as &$element) {
23
                unset($element['inenv']);
24
            }
25
        }
26
27
        if ($mode == 'deploy') {
28
            $headers = ['Variable', 'In Source', 'In .env'];
29
            foreach ($data as &$element) {
30
                unset($element['inenvexample']);
31
            }
32
        }
33
34
        $table = new Table(new ConsoleOutput);
35
36
        $table->setHeaders($headers)->setRows($data)->render();
37
    }
38
}
39