Google\Spreadsheet\WorksheetFeed::getById PHP Method

getById() public method

Get a worksheet by id
public getById ( string $id ) : Worksheet
$id string of the worksheet
return Worksheet
    public function getById($id)
    {
        $feedId = $this->xml->id->__toString();
        foreach ($this->xml->entry as $entry) {
            if ($entry->id == $feedId . '/' . $id) {
                return new Worksheet($entry);
            }
        }
        throw new WorksheetNotFoundException();
    }

Usage Example

 /**
  * @expectedException Google\Spreadsheet\Exception\WorksheetNotFoundException
  */
 public function testGetByIdException()
 {
     $worksheetFeed = new WorksheetFeed($this->getSimpleXMLElement("worksheet-feed"));
     $this->assertTrue(is_null($worksheetFeed->getById("od7")));
 }