original_string: public function saveSnapshot($dir){
          
          if(!is_dir($dir)){
              mkdir($dir, 0775, true);
          }
          
          $jpeg = $this->takeSnapShot();
          $file = $dir.'/'.date('Y_m_d_H_i_s').'.jpg';
          if(file_put_contents($file, $jpeg)){
              return $file;
          }
          
          return '';
      }
code: public function saveSnapshot($dir){
          
          if(!is_dir($dir)){
              mkdir($dir, 0775, true);
          }
          
          $jpeg = $this->takeSnapShot();
          $file = $dir.'/'.date('Y_m_d_H_i_s').'.jpg';
          if(file_put_contents($file, $jpeg)){
              return $file;
          }
          
          return '';
      }
code_tokens: public function saveSnapshot ( $ dir ) { if ( ! is_dir ( $ dir ) ) { mkdir ( $ dir , 0775 , true ) ; } $ jpeg = $ this -> takeSnapShot ( ) ; $ file = $ dir . '/' . date ( 'Y_m_d_H_i_s' ) . '.jpg' ; if ( file_put_contents ( $ file , $ jpeg ) ) { return $ file ; } return '' ; }
docstring: Retrieves and stores a snapshot by date
  @param type $dir
  @return string Path if saved, empty string if not
docstring_tokens: Retrieves and stores a snapshot by date