original_string: public function pushTweet($tweet)
      {
          if ($this->maxPushesPerHour > 0 && $this->cache) {
              $hourAgo = new \DateTime('- 1 hour');
              /** @var \DateTime[] $tweetTimes */
              $tweetTimes = $this->cache->fetch(static::CACHE_KEY) ?: [];
              foreach ($tweetTimes as $k => $time) {
                  if ($time < $hourAgo) {
                      unset($tweetTimes[$k]);
                  }
              }
              if (($count = count($tweetTimes)) >= $this->maxPushesPerHour) {
                  throw new MaxPushesPerHourException("Cannot send push, $count have already been sent. The limit is {$this->maxPushesPerHour}");
              }
              $tweetTimes[] = new \DateTime();
              $this->cache->save(static::CACHE_KEY, $tweetTimes, 3600);
          }
  
          $m = $this->getMessageForTweet($tweet);
  
          if ($this->topicArn) {
              $this->messages->send($m, $this->topicArn);
          } else {
              $this->messages->broadcast($m);
          }
      }
code: public function pushTweet($tweet)
      {
          if ($this->maxPushesPerHour > 0 && $this->cache) {
              $hourAgo = new \DateTime('- 1 hour');
              /** @var \DateTime[] $tweetTimes */
              $tweetTimes = $this->cache->fetch(static::CACHE_KEY) ?: [];
              foreach ($tweetTimes as $k => $time) {
                  if ($time < $hourAgo) {
                      unset($tweetTimes[$k]);
                  }
              }
              if (($count = count($tweetTimes)) >= $this->maxPushesPerHour) {
                  throw new MaxPushesPerHourException("Cannot send push, $count have already been sent. The limit is {$this->maxPushesPerHour}");
              }
              $tweetTimes[] = new \DateTime();
              $this->cache->save(static::CACHE_KEY, $tweetTimes, 3600);
          }
  
          $m = $this->getMessageForTweet($tweet);
  
          if ($this->topicArn) {
              $this->messages->send($m, $this->topicArn);
          } else {
              $this->messages->broadcast($m);
          }
      }
code_tokens: public function pushTweet ( $ tweet ) { if ( $ this -> maxPushesPerHour > 0 && $ this -> cache ) { $ hourAgo = new \ DateTime ( '- 1 hour' ) ; /** @var \DateTime[] $tweetTimes */ $ tweetTimes = $ this -> cache -> fetch ( static :: CACHE_KEY ) ? : [ ] ; foreach ( $ tweetTimes as $ k => $ time ) { if ( $ time < $ hourAgo ) { unset ( $ tweetTimes [ $ k ] ) ; } } if ( ( $ count = count ( $ tweetTimes ) ) >= $ this -> maxPushesPerHour ) { throw new MaxPushesPerHourException ( "Cannot send push, $count have already been sent. The limit is {$this->maxPushesPerHour}" ) ; } $ tweetTimes [ ] = new \ DateTime ( ) ; $ this -> cache -> save ( static :: CACHE_KEY , $ tweetTimes , 3600 ) ; } $ m = $ this -> getMessageForTweet ( $ tweet ) ; if ( $ this -> topicArn ) { $ this -> messages -> send ( $ m , $ this -> topicArn ) ; } else { $ this -> messages -> broadcast ( $ m ) ; } }
docstring: Send a tweet to everyone
  
  @param array $tweet
  @throws MaxPushesPerHourException
  @throws \Mcfedr\AwsPushBundle\Exception\PlatformNotConfiguredException
docstring_tokens: Send a tweet to everyone