/**
  * Escapes a phrase with () or "" depending on type
  *
  * @param Phrase[]    $phrases
  * @param null|string $type (any|all|null) any = (my phrase), all = "my phrase", null = do nothing
  *
  * @return array
  */
 private function escapePhrasesForExpression(array $phrases, $type = null)
 {
     $return = [];
     switch ($type) {
         case 'any':
             $s = '(%s)';
             break;
         case 'all':
             $s = '"%s"';
             break;
         default:
             $s = '%s';
     }
     foreach ($phrases as $phrase) {
         if (!$phrase instanceof Phrase) {
             $phrase = new Phrase($phrase);
         }
         if ($phrase->isEmpty()) {
             continue;
         }
         if ($phrase->isWordGroup() && !$phrase->isPhrase()) {
             $return[] = sprintf($s, $phrase);
         } else {
             $return[] = (string) $phrase;
         }
     }
     return $return;
 }