Code Duplication    Length = 31-31 lines in 2 locations

src/CL/Table/Renderer/AsciiRenderer.php 2 locations

@@ 47-77 (lines=31) @@
44
    /**
45
     * @param Table $table
46
     */
47
    private function writeHeader(Table $table)
48
    {
49
        $line = '';
50
51
        foreach ($table->getColumns() as $column) {
52
            if (!$line) {
53
                $line .= '|';
54
            }
55
56
            $columnWidth = $this->getMaxColumnWidth($column);
57
            $value = $column->getLabel();
58
            $suffix = '';
59
            $prefix = '';
60
61
            if ($value) {
62
                $prefix = ' ';
63
                $missingSpaces = $columnWidth - mb_strlen($value) + mb_strlen($prefix);
64
                if ($missingSpaces > 0) {
65
                    $suffix = str_repeat(' ', $missingSpaces);
66
                } else {
67
                    $suffix = ' ';
68
                }
69
            }
70
71
            $line .= sprintf('%s%s%s|', $prefix, $value, $suffix);
72
        }
73
74
        if ($line) {
75
            $this->writeLine($line);
76
        }
77
    }
78
79
    /**
80
     * @param Table $table
@@ 82-112 (lines=31) @@
79
    /**
80
     * @param Table $table
81
     */
82
    private function writeBody(Table $table)
83
    {
84
        foreach ($table->toArray() as $row) {
85
            $line = '';
86
            foreach ($row as $column => $value) {
87
                if (!$line) {
88
                    $line .= '|';
89
                }
90
91
                $columnWidth = $this->getMaxColumnWidth($table->getColumn($column));
92
                $suffix = '';
93
                $prefix = '';
94
95
                if ($value) {
96
                    $prefix = ' ';
97
                    $missingSpaces = $columnWidth - mb_strlen($value) + mb_strlen($prefix);
98
                    if ($missingSpaces > 0) {
99
                        $suffix = str_repeat(' ', $missingSpaces);
100
                    } else {
101
                        $suffix = ' ';
102
                    }
103
                }
104
105
                $line .= sprintf('%s%s%s|', $prefix, $value, $suffix);
106
            }
107
108
            if ($line) {
109
                $this->writeLine($line);
110
            }
111
        }
112
    }
113
114
    /**
115
     * @param Column $column