Completed
Push — master ( 1ee6cc...3645f8 )
by Sebastian
01:45
created

Util   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A trimEmptyLines() 0 10 3
1
<?php
2
/**
3
 * This file is part of SebastianFeldmann\Cli.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace SebastianFeldmann\Cli\Output;
11
12
/**
13
 * Class Util
14
 *
15
 * @package SebastianFeldmann\Cli
16
 * @author  Sebastian Feldmann <[email protected]>
17
 * @link    https://github.com/sebastianfeldmann/cli
18
 * @since   Class available since Release 2.1.0
19
 */
20
class Util
21
{
22
    /**
23
     * Remove empty entries at the end of an array.
24
     *
25
     * @param  array $lines
26
     * @return array
27
     */
28 8
    public static function trimEmptyLines(array $lines) : array
29
    {
30 8
        for ($last = count($lines) - 1; $last > -1; $last--) {
31 8
            if (!empty($lines[$last])) {
32 6
                return $lines;
33
            }
34 4
            unset($lines[$last]);
35
        }
36 2
        return $lines;
37
    }
38
}
39