Kraken\Console\Client\Command\Command::successData PHP Method

successData() protected method

protected successData ( mixed[] $input )
$input mixed[]
    protected function successData($input)
    {
        print "Success\n";
        $header = [];
        $data = [];
        $lengths = [];
        foreach ($input[0] as $key => $value) {
            $header[$key] = $key;
            $lengths[$key] = 0;
        }
        array_unshift($input, $header);
        foreach ($input as &$row) {
            foreach ($row as $key => $value) {
                if ($value === null) {
                    $value = 'null';
                    $row[$key] = $value;
                }
                $mbLen = mb_strlen($value);
                if ($mbLen > $lengths[$key]) {
                    $lengths[$key] = $mbLen;
                }
            }
        }
        unset($row);
        foreach ($input as &$row) {
            foreach ($row as $key => $value) {
                $mbLen = mb_strlen($value);
                if ($mbLen < $lengths[$key]) {
                    $value .= str_repeat(' ', $lengths[$key] - $mbLen);
                    $row[$key] = $value;
                }
            }
            $data[] = $row;
        }
        unset($row);
        $output = "";
        foreach ($data as &$row) {
            $output .= "|";
            foreach ($row as $key => $value) {
                $output .= " " . $value . " |";
            }
            $output .= "\n";
        }
        unset($row);
        print $output;
    }