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

Config   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A processCommand() 0 8 2
A printArray() 0 17 4
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