/**
  * Parses the content into the Event.
  *
  * @param  string     $prizes
  * @throws \Exception
  */
 private function parsePrizes($prizes)
 {
     try {
         $prizes = json_decode($prizes);
         foreach ($prizes->prizes as $item) {
             $prize = new Prize();
             $prize->setSponsorName($item->sponsor);
             $prize->setPrizeTitle($item->prize);
             $prize->setTweetMessage($item->tweet_message);
             $this->event->addPrize($prize);
         }
     } catch (\Exception $error) {
         throw new \Exception($error->getMessage());
     }
 }
 /**
  * @param OutputInterface $output
  * @param Prize           $prize
  */
 private function tweetWinner(OutputInterface $output, Prize $prize)
 {
     if ($this->isToTweet($output, $prize->getTweetMessage())) {
         $tweetCmd = $this->getApplication()->find('twitter:tweet');
         $arguments = array('command' => 'twitter:tweet', 'tweet_message' => $prize->getTweetMessage());
         $input = new ArrayInput($arguments);
         $tweetCmd->run($input, $output);
     }
 }
 /**
  * Saves the prize winner with the prize information
  *
  * @param  string            $eventId
  * @param  Prize             $prize
  * @return null
  * @throws \RuntimeException
  */
 public function saveWinner($eventId, Prize $prize)
 {
     $filename = sprintf($this->winnersDir, $eventId);
     $prizes = array();
     if (file_exists($filename)) {
         $contents = file_get_contents($filename);
         $prizes = json_decode($contents);
     }
     $prizes[] = $prize->toArray();
     $saved = file_put_contents($filename, json_encode($prizes));
     if (false === $saved) {
         throw new \RuntimeException("Failed to write on the file {$eventId}_winners.json");
     }
 }