title = $title; } $this->return = Buffering\Callback::do(function() use($result) { $success = Lang::default('ZN\Console\ConsoleDefaultLanguage')::select('Success', 'success'); $error = Lang::default('ZN\Console\ConsoleDefaultLanguage')::select('Error', 'error'); $nodata = 'No Data'; if( $result === true || $result === NULL ) { echo $success; } elseif( $result === false ) { echo $error; } else { if( is_array($result) ) { if( ! empty($result) ) { $this->print = $result; } else { echo $nodata; } } else { if( ! empty($result) ) { echo $result; } else { echo $nodata; } } } }); if( isset($this->print) ) { $this->outputMultipleResult(); } else { $this->outputSingleResult(); } } /** * Protected Line */ protected function line() { return '+' . str_repeat ( '-', (($returnLength = strlen($this->return)) < ($titleLength = (strlen($this->title))) ? $titleLength : $returnLength )) . '--+' . EOL; } /** * Protected Title */ protected function title() { return '| '.$this->title.' ' . str_repeat ( ' ', ($returnLength = strlen($this->return)) >= ($titleLength = strlen($this->title)) ? $returnLength - $titleLength : 0 ) . '|' . EOL; } /** * Protected Content */ protected function content() { return '| ' . $this->return . str_repeat ( ' ', (($returnLength = strlen($this->return)) < ($titleLength = strlen($this->title)) ? $titleLength - $returnLength + 1 : 1 )) . '|'.EOL; } /** * Protected output single result */ protected function outputSingleResult() { echo EOL; echo $this->line(); echo $this->title(); echo $this->line(); echo $this->content(); echo $this->line(); } /** * Protected output multiple result */ protected function outputMultipleResult() { $this->return = $max = max($this->print) . ' '; echo EOL; echo $this->line(); echo $this->title(); echo $this->line(); foreach( $this->print as $key => $ret ) { $diff = strlen($max) - strlen($return = $key . ' | ' . $ret); $this->return = $return . str_repeat(' ', $diff); echo $this->content(); echo $this->line(); } } }