Completed
Push — commands ( fc1c01...9f315c )
by Arnaud
01:43
created

Config::printArray()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 4
nc 2
nop 2
1
<?php
2
/*
3
 * This file is part of the PHPoole package.
4
 *
5
 * Copyright (c) Arnaud Ligny <[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
11
namespace PHPoole\Command;
12
13
class Config extends AbstractCommand
14
{
15
    public function processCommand()
16
    {
17
        try {
18
            $this->wl($this->printArray($this->getPHPoole()->getConfig()->getAllAsArray()));
19
        } catch (\Exception $e) {
20
            throw new \Exception(sprintf($e->getMessage()));
21
        }
22
    }
23
24
    private function printArray($array, $i = -4)
25
    {
26
        $return = '';
27
28
        if (is_array($array)) {
29
            $i += 4;
30
            foreach ($array as $key=>$val) {
31
                if (is_array($val)) {
32
                    $return .= str_repeat(' ', $i)."$key:\n".$this->printArray($val, $i);
33
                } else {
34
                    $return .= str_repeat(' ', $i)."$key: $val\n";
35
                }
36
            }
37
        }
38
39
        return $return;
40
    }
41
}
42