Skip to content

Commit fb82cdc

Browse files
authored
Merge pull request #159 from andrey82k/master
get spreadsheet by id
2 parents 9ad5f2a + b5ca14f commit fb82cdc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Google/Spreadsheet/SpreadsheetFeed.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,24 @@ public function getByTitle($title)
100100
throw new SpreadsheetNotFoundException();
101101
}
102102

103+
/**
104+
* Gets a spreadhseet from the feed by its ID in google drive.
105+
*
106+
* @param string $id
107+
*
108+
* @return Spreadsheet
109+
*
110+
* @throws SpreadsheetNotFoundException
111+
*/
112+
public function getById($id)
113+
{
114+
foreach($this->xml->entry as $entry) {
115+
if($entry->id->__toString() == $id) {
116+
return new Spreadsheet($entry);
117+
}
118+
}
119+
120+
throw new SpreadsheetNotFoundException();
121+
}
122+
103123
}

0 commit comments

Comments
 (0)