Skip to content

Commit

Permalink
Merge pull request #159 from andrey82k/master
Browse files Browse the repository at this point in the history
get spreadsheet by id
  • Loading branch information
asimlqt committed Nov 9, 2016
2 parents 9ad5f2a + b5ca14f commit fb82cdc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Google/Spreadsheet/SpreadsheetFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,24 @@ public function getByTitle($title)
throw new SpreadsheetNotFoundException();
}

/**
* Gets a spreadhseet from the feed by its ID in google drive.
*
* @param string $id
*
* @return Spreadsheet
*
* @throws SpreadsheetNotFoundException
*/
public function getById($id)
{
foreach($this->xml->entry as $entry) {
if($entry->id->__toString() == $id) {
return new Spreadsheet($entry);
}
}

throw new SpreadsheetNotFoundException();
}

}

0 comments on commit fb82cdc

Please sign in to comment.