original_string: protected function writeGoogleSheetData(
          OutputInterface $output,
          \Google_Service_Sheets $service,
          \Google_Service_Drive_DriveFile $spreadsheet
      ) {
          $output->writeln('<info>The URL is a Google Sheets file</info>');
          $output->writeln('Name: '.$spreadsheet->getName());
  
          // Getting the list of sheets
          $spreadsheetData = $service->spreadsheets->get($spreadsheet->getId(), [
              'includeGridData' => false
          ]);
          $sheetsNames = [];
          foreach ($spreadsheetData->getSheets() as $sheet) {
              /** @var \Google_Service_Sheets_Sheet $sheet (the SDK type hint is incorrect) */
              $sheetsNames[] = $sheet->getProperties()->getTitle();
          }
          if ($sheetsNames) {
              $output->writeln('Sheets: '.implode(', ', $sheetsNames));
          } else {
              $output->writeln('The file has no sheets');
              return;
          }
  
          // Getting a piece of the first sheet content
          $spreadsheetData = $service->spreadsheets->get($spreadsheet->getId(), [
              'includeGridData' => true,
              'ranges' => ['A1:E5'] // Google returns only the data of the first sheet for this request
          ]);
          $output->writeln('A piece of the first sheet content:');
          $this->writeGoogleSheetTable($output, $spreadsheetData->getSheets()[0]);
      }
code: protected function writeGoogleSheetData(
          OutputInterface $output,
          \Google_Service_Sheets $service,
          \Google_Service_Drive_DriveFile $spreadsheet
      ) {
          $output->writeln('<info>The URL is a Google Sheets file</info>');
          $output->writeln('Name: '.$spreadsheet->getName());
  
          // Getting the list of sheets
          $spreadsheetData = $service->spreadsheets->get($spreadsheet->getId(), [
              'includeGridData' => false
          ]);
          $sheetsNames = [];
          foreach ($spreadsheetData->getSheets() as $sheet) {
              /** @var \Google_Service_Sheets_Sheet $sheet (the SDK type hint is incorrect) */
              $sheetsNames[] = $sheet->getProperties()->getTitle();
          }
          if ($sheetsNames) {
              $output->writeln('Sheets: '.implode(', ', $sheetsNames));
          } else {
              $output->writeln('The file has no sheets');
              return;
          }
  
          // Getting a piece of the first sheet content
          $spreadsheetData = $service->spreadsheets->get($spreadsheet->getId(), [
              'includeGridData' => true,
              'ranges' => ['A1:E5'] // Google returns only the data of the first sheet for this request
          ]);
          $output->writeln('A piece of the first sheet content:');
          $this->writeGoogleSheetTable($output, $spreadsheetData->getSheets()[0]);
      }
code_tokens: protected function writeGoogleSheetData ( OutputInterface $ output , \ Google_Service_Sheets $ service , \ Google_Service_Drive_DriveFile $ spreadsheet ) { $ output -> writeln ( '<info>The URL is a Google Sheets file</info>' ) ; $ output -> writeln ( 'Name: ' . $ spreadsheet -> getName ( ) ) ; // Getting the list of sheets $ spreadsheetData = $ service -> spreadsheets -> get ( $ spreadsheet -> getId ( ) , [ 'includeGridData' => false ] ) ; $ sheetsNames = [ ] ; foreach ( $ spreadsheetData -> getSheets ( ) as $ sheet ) { /** @var \Google_Service_Sheets_Sheet $sheet (the SDK type hint is incorrect) */ $ sheetsNames [ ] = $ sheet -> getProperties ( ) -> getTitle ( ) ; } if ( $ sheetsNames ) { $ output -> writeln ( 'Sheets: ' . implode ( ', ' , $ sheetsNames ) ) ; } else { $ output -> writeln ( 'The file has no sheets' ) ; return ; } // Getting a piece of the first sheet content $ spreadsheetData = $ service -> spreadsheets -> get ( $ spreadsheet -> getId ( ) , [ 'includeGridData' => true , 'ranges' => [ 'A1:E5' ] // Google returns only the data of the first sheet for this request ] ) ; $ output -> writeln ( 'A piece of the first sheet content:' ) ; $ this -> writeGoogleSheetTable ( $ output , $ spreadsheetData -> getSheets ( ) [ 0 ] ) ; }
docstring: Prints a URL ping result as if the result is a Google Sheets file
  
  @param OutputInterface $output
  @param \Google_Service_Sheets $service The Sheets API service
  @param \Google_Service_Drive_DriveFile $spreadsheet The file
  @link https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get
docstring_tokens: Prints a URL ping result as if the result is a Google Sheets file