Google\Spreadsheet\SpreadsheetFeed::getByTitle PHP 메소드

getByTitle() 공개 메소드

Gets a spreadhseet from the feed by its title. i.e. the name of the spreadsheet in google drive. This method will return only the first spreadsheet found with the specified title.
public getByTitle ( string $title ) : Spreadsheet
$title string
리턴 Spreadsheet
    public function getByTitle($title)
    {
        foreach ($this->xml->entry as $entry) {
            if ($entry->title->__toString() == $title) {
                return new Spreadsheet($entry);
            }
        }
        throw new SpreadsheetNotFoundException();
    }

Usage Example

 public function testGetByTitle()
 {
     $xml = file_get_contents(__DIR__ . '/xml/spreadsheet-feed.xml');
     $spreadsheetFeed = new SpreadsheetFeed($xml);
     $this->assertTrue($spreadsheetFeed->getByTitle('Test Spreadsheet') instanceof Spreadsheet);
     $this->assertTrue(is_null($spreadsheetFeed->getByTitle('No Spreadsheet')));
 }
All Usage Examples Of Google\Spreadsheet\SpreadsheetFeed::getByTitle