Ejemplo n.º 1
0
 /**
  * Execute a basic terminal object
  *
  * @param \League\CLImate\TerminalObject\Basic\BasicTerminalObject $obj
  * @return void
  */
 public function execute($obj)
 {
     $results = Helper::toArray($obj->result());
     $this->output->persist();
     foreach ($results as $result) {
         if ($obj->sameLine()) {
             $this->output->sameLine();
         }
         $this->output->write($obj->getParser()->apply($result));
     }
     $this->output->persist(false);
 }
Ejemplo n.º 2
0
 /**
  * Stringify the codes
  *
  * @param  mixed  $codes
  *
  * @return string
  */
 protected function codeStr($codes)
 {
     // If we get something that is already a code string, just pass it back
     if (!is_array($codes) && strstr($codes, ';')) {
         return $codes;
     }
     $codes = Helper::toArray($codes);
     // Sort for the sake of consistency and testability
     sort($codes);
     return implode(';', $codes);
 }
Ejemplo n.º 3
0
 /**
  * Get the writers based on their keys
  *
  * @param string|array $keys
  *
  * @return array
  */
 protected function getWriters($keys)
 {
     $writers = array_flip(Helper::toArray($keys));
     return Helper::flatten(array_intersect_key($this->writers, $writers));
 }
Ejemplo n.º 4
0
 /**
  * Compile an array of the current codes
  *
  * @return array
  */
 public function current()
 {
     $full_current = [];
     foreach ($this->style as $style) {
         $full_current = array_merge($full_current, Helper::toArray($style->current()));
     }
     $full_current = array_filter($full_current);
     return array_values($full_current);
 }