original_string: public function afterStep(StepEvent $event) {
          $color = $this->getResultColorCode($event->getResult());
          $capture = $this->captureAll || $color == 'failed';
          if ($capture) {
              try {
                  $screenshot = $this->driver->getScreenshot();
                  if ($screenshot) {
                      $date = new \DateTime('now');
                      $fileName = $this->screenShotPrefix . $date->format('Y-m-d H.i.s') . '.png';
                      $file = $this->screenShotDirectory . DIRECTORY_SEPARATOR . $fileName;
                      file_put_contents($file, $screenshot);
                      $this->screenShotMarkup .= '<div class="screenshot">';
                      $this->screenShotMarkup .= sprintf('<a href="#" class="screenshot-toggler">Toggle screenshot for ' . $event->getStep()->getText() . '</a>');
                      $this->screenShotMarkup .= sprintf('<img src="%s" />', $fileName);
                      $this->screenShotMarkup .= '</div>';
                  }
              } catch (\Exception $e) {
                  $this->screenShotMarkup .= '<div class="screenshot">';
                  $this->screenShotMarkup .= sprintf('<em>Error while taking screenshot for ' . $event->getStep()->getText() . ' : %s</em>', htmlspecialchars($e->getMessage()));
                  $this->screenShotMarkup .= '</div>';
              }
          }
          if ($this->inBackground && $this->isBackgroundPrinted) {
              return;
          }
  
          if (!$this->inBackground && $this->inOutlineExample) {
              $this->delayedStepEvents[] = $event;
  
              return;
          }
  
          $this->printStep(
              $event->getStep(),
              $event->getResult(),
              $event->getDefinition(),
              $event->getSnippet(),
              $event->getException()
          );
          $this->writeln($this->screenShotMarkup);
          $this->screenShotMarkup = '';
  
      }
code: public function afterStep(StepEvent $event) {
          $color = $this->getResultColorCode($event->getResult());
          $capture = $this->captureAll || $color == 'failed';
          if ($capture) {
              try {
                  $screenshot = $this->driver->getScreenshot();
                  if ($screenshot) {
                      $date = new \DateTime('now');
                      $fileName = $this->screenShotPrefix . $date->format('Y-m-d H.i.s') . '.png';
                      $file = $this->screenShotDirectory . DIRECTORY_SEPARATOR . $fileName;
                      file_put_contents($file, $screenshot);
                      $this->screenShotMarkup .= '<div class="screenshot">';
                      $this->screenShotMarkup .= sprintf('<a href="#" class="screenshot-toggler">Toggle screenshot for ' . $event->getStep()->getText() . '</a>');
                      $this->screenShotMarkup .= sprintf('<img src="%s" />', $fileName);
                      $this->screenShotMarkup .= '</div>';
                  }
              } catch (\Exception $e) {
                  $this->screenShotMarkup .= '<div class="screenshot">';
                  $this->screenShotMarkup .= sprintf('<em>Error while taking screenshot for ' . $event->getStep()->getText() . ' : %s</em>', htmlspecialchars($e->getMessage()));
                  $this->screenShotMarkup .= '</div>';
              }
          }
          if ($this->inBackground && $this->isBackgroundPrinted) {
              return;
          }
  
          if (!$this->inBackground && $this->inOutlineExample) {
              $this->delayedStepEvents[] = $event;
  
              return;
          }
  
          $this->printStep(
              $event->getStep(),
              $event->getResult(),
              $event->getDefinition(),
              $event->getSnippet(),
              $event->getException()
          );
          $this->writeln($this->screenShotMarkup);
          $this->screenShotMarkup = '';
  
      }
code_tokens: public function afterStep ( StepEvent $ event ) { $ color = $ this -> getResultColorCode ( $ event -> getResult ( ) ) ; $ capture = $ this -> captureAll || $ color == 'failed' ; if ( $ capture ) { try { $ screenshot = $ this -> driver -> getScreenshot ( ) ; if ( $ screenshot ) { $ date = new \ DateTime ( 'now' ) ; $ fileName = $ this -> screenShotPrefix . $ date -> format ( 'Y-m-d H.i.s' ) . '.png' ; $ file = $ this -> screenShotDirectory . DIRECTORY_SEPARATOR . $ fileName ; file_put_contents ( $ file , $ screenshot ) ; $ this -> screenShotMarkup .= '<div class="screenshot">' ; $ this -> screenShotMarkup .= sprintf ( '<a href="#" class="screenshot-toggler">Toggle screenshot for ' . $ event -> getStep ( ) -> getText ( ) . '</a>' ) ; $ this -> screenShotMarkup .= sprintf ( '<img src="%s" />' , $ fileName ) ; $ this -> screenShotMarkup .= '</div>' ; } } catch ( \ Exception $ e ) { $ this -> screenShotMarkup .= '<div class="screenshot">' ; $ this -> screenShotMarkup .= sprintf ( '<em>Error while taking screenshot for ' . $ event -> getStep ( ) -> getText ( ) . ' : %s</em>' , htmlspecialchars ( $ e -> getMessage ( ) ) ) ; $ this -> screenShotMarkup .= '</div>' ; } } if ( $ this -> inBackground && $ this -> isBackgroundPrinted ) { return ; } if ( ! $ this -> inBackground && $ this -> inOutlineExample ) { $ this -> delayedStepEvents [ ] = $ event ; return ; } $ this -> printStep ( $ event -> getStep ( ) , $ event -> getResult ( ) , $ event -> getDefinition ( ) , $ event -> getSnippet ( ) , $ event -> getException ( ) ) ; $ this -> writeln ( $ this -> screenShotMarkup ) ; $ this -> screenShotMarkup = '' ; }
docstring: Listens to "step.after" event.
  
  @param StepEvent $event
  
  @uses printStep()
docstring_tokens: Listens to step . after event .