/**
  * @inheritDoc
  */
 public function getItems(Query $query)
 {
     $config = $this->app->getConfig();
     // remove spaces from number
     $number = str_replace(' ', '', $query->getArgument());
     // item is only valid if a number is given
     $valid = $number ? true : false;
     // auto completion is only needed when no number is given
     $autoComplete = !$number ? $query->getCommandWithoutPrefix() : null;
     // only a valid number is callable ;-)
     if ($number && !preg_match('/^\\+?\\d+$/', $number)) {
         return array();
     }
     $items = array();
     foreach ($config['lines'] as $line) {
         // change subtitle whether a number is given or not
         if ($number) {
             $subtitle = sprintf('Calling "%s" with line "%s"', $number, $line['title']);
         } else {
             $subtitle = sprintf('Enter number to call with line "%s"', $line['title']);
         }
         // add new line item
         $items[] = new Item($line['title'], $subtitle, $line['icon'], sprintf('%s %s %s', $query->getCommand(), $number, $line['uri']), $autoComplete, $line['uri'], $valid);
     }
     return $items;
 }
 /**
  * Runs the application action with the given query.
  *
  * @param Query $query The query
  *
  * @return null
  */
 public function action(Query $query)
 {
     foreach ($this->commands as $command) {
         if ($command->getCommand() === $query->getCommand()) {
             $command->invoke($query);
             return;
         }
     }
     throw new \LogicException(sprintf('Could not invoke command. No registered command for "%s" found.', $query->getCommand()));
 }
 /**
  * @inheritDoc
  */
 public function supports(Query $query)
 {
     return $this->getCommand() === $query->getCommand();
 }
 /**
  * @inheritDoc
  */
 public function supports(Query $query)
 {
     return 0 === strpos($this->getCommand(), $query->getCommand());
 }
 public function testValidQueryCommandUppercase()
 {
     $queryString = 'CALL:NuMBer 0160123465789';
     $query = new Query($queryString);
     $this->assertSame('call:number', $query->getCommand());
 }