TableBuilder   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B outputTable() 0 22 5
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