/**
  * 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()));
 }
 /**
  * Extracts and returns the line from the query.
  *
  * @param Query $query Query
  *
  * @return string Line
  */
 public function getLineFromQuery(Query $query)
 {
     $argument = $query->getArgument();
     if (false === strpos($argument, '@')) {
         return null;
     }
     $arguments = explode(' ', $argument);
     $line = array_pop($arguments);
     // hack due to a possible bug in Yealink firmware
     // we must strip the @ char and the host from uri
     // otherwise the line would not be recognised by the phone
     $line = explode('@', $line);
     $line = $line[0];
     return $line;
 }
 /**
  * @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 testArgumentWithSpaces()
 {
     $queryString = 'call:number 0160123465789 line2';
     $query = new Query($queryString);
     $this->assertSame('0160123465789 line2', $query->getArgument());
 }