예제 #1
0
 /**
  * @param  ApplicationUser[] $users
  * @param  object            $object
  * @param  string            $language
  * @return DefaultMessage
  */
 public function buildMessage(array $users, $object, $language = null)
 {
     $filteredUsers = self::filterUsers($users);
     if (count($filteredUsers) === 0) {
         return null;
     }
     $messageResource = $this->extractor->extractMessage($object);
     if ($messageResource === null) {
         return null;
     }
     $language = $language ?: self::getLanguage($filteredUsers);
     try {
         $translatedText = $this->resourceTranslator->translate($language, $messageResource);
     } catch (\IntlException $e) {
         $translatedText = $messageResource->getKey();
     }
     return new DefaultMessage($filteredUsers, $translatedText);
 }
 private function givenGameResultExtractorCanExtractMessage()
 {
     $this->gameResultExtractor->shouldReceive('extractMessage')->with($this->gameResult)->andReturn($this->message)->once();
 }
 private function givenSecondSubExtractorCannotExtractMessage()
 {
     $this->subExTwo->shouldReceive('extractMessage')->with($this->event)->andReturn($this->message);
 }
예제 #4
0
 private function givenItCanNotExtractMessage()
 {
     $this->extractor->shouldReceive('extractMessage')->with($this->object)->andReturn(null);
 }