Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Concerns/SheetsDrive.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function spreadsheetList(): array
return $list;
}

public function setDriveService(mixed $drive): static
public function setDriveService(mixed $drive): self
{
$this->drive = $drive;

Expand Down
8 changes: 4 additions & 4 deletions src/Concerns/SheetsValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,28 @@ public function ranges(): ?string
return $this->range;
}

public function range(string $range): static
public function range(string $range): self
{
$this->range = $range;

return $this;
}

public function majorDimension(string $majorDimension): static
public function majorDimension(string $majorDimension): self
{
$this->majorDimension = $majorDimension;

return $this;
}

public function valueRenderOption(string $valueRenderOption): static
public function valueRenderOption(string $valueRenderOption): self
{
$this->valueRenderOption = $valueRenderOption;

return $this;
}

public function dateTimeRenderOption(string $dateTimeRenderOption): static
public function dateTimeRenderOption(string $dateTimeRenderOption): self
{
$this->dateTimeRenderOption = $dateTimeRenderOption;

Expand Down
20 changes: 10 additions & 10 deletions src/Contracts/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@

interface Factory
{
public function setService(mixed $service): static;
public function setService(mixed $service): self;

public function getService(): Sheets;

/**
* set access_token and set new service.
*/
public function setAccessToken(array|string $token): static;
public function setAccessToken(array|string $token): self;

public function spreadsheet(string $spreadsheetId): static;
public function spreadsheet(string $spreadsheetId): self;

public function spreadsheetByTitle(string $title): static;
public function spreadsheetByTitle(string $title): self;

public function sheet(string $sheet): static;
public function sheet(string $sheet): self;

public function sheetById(string $sheetId): static;
public function sheetById(string $sheetId): self;

public function sheetList(): array;

Expand All @@ -36,7 +36,7 @@ public function collection(array $header, array|Collection $rows): Collection;

public function spreadsheetList(): array;

public function setDriveService(mixed $drive): static;
public function setDriveService(mixed $drive): self;

public function getDriveService(): mixed;

Expand All @@ -60,11 +60,11 @@ public function append(

public function ranges(): ?string;

public function range(string $range): static;
public function range(string $range): self;

public function majorDimension(string $majorDimension): static;
public function majorDimension(string $majorDimension): self;

public function dateTimeRenderOption(string $dateTimeRenderOption): static;
public function dateTimeRenderOption(string $dateTimeRenderOption): self;

public function getSpreadsheetId(): string;

Expand Down
22 changes: 11 additions & 11 deletions src/Facades/Sheets.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
use Revolution\Google\Sheets\Contracts\Factory;

/**
* @method static static setAccessToken(array|string $token)
* @method static static spreadsheet(string $spreadsheetId)
* @method static static spreadsheetByTitle(string $title)
* @method static static sheet(string $sheet)
* @method static static sheetById(string $sheetId)
* @method static self setAccessToken(array|string $token)
* @method static self spreadsheet(string $spreadsheetId)
* @method static self spreadsheetByTitle(string $title)
* @method static self sheet(string $sheet)
* @method static self sheetById(string $sheetId)
* @method static array sheetList()
* @method static BatchUpdateSpreadsheetResponse addSheet(string $sheetTitle)
* @method static BatchUpdateSpreadsheetResponse deleteSheet(string $sheetTitle)
Expand All @@ -28,14 +28,14 @@
* @method static BatchUpdateValuesResponse update(array $value, string $valueInputOption = 'RAW')
* @method static ClearValuesResponse|null clear()
* @method static AppendValuesResponse append(array $values, string $valueInputOption = 'RAW', string $insertDataOption = 'OVERWRITE')
* @method static static range(string $range)
* @method static static majorDimension(string $majorDimension)
* @method static static valueRenderOption(string $valueRenderOption)
* @method static static dateTimeRenderOption(string $dateTimeRenderOption)
* @method static self range(string $range)
* @method static self majorDimension(string $majorDimension)
* @method static self valueRenderOption(string $valueRenderOption)
* @method static self dateTimeRenderOption(string $dateTimeRenderOption)
* @method static GoogleSheets getService()
* @method static static setService(mixed $service)
* @method static self setService(mixed $service)
* @method static Drive getDriveService()
* @method static static setDriveService(mixed $drive)
* @method static self setDriveService(mixed $drive)
* @method static array spreadsheetList()
* @method static object spreadsheetProperties()
* @method static object sheetProperties()
Expand Down
12 changes: 6 additions & 6 deletions src/SheetsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SheetsClient implements Factory

protected ?string $sheet = null;

public function setService(mixed $service): static
public function setService(mixed $service): self
{
$this->service = $service;

Expand All @@ -45,7 +45,7 @@ public function getService(): GoogleSheets
/**
* set access_token and set new service.
*/
public function setAccessToken(#[\SensitiveParameter] array|string $token): static
public function setAccessToken(#[\SensitiveParameter] array|string $token): self
{
Google::getCache()->clear();

Expand All @@ -64,14 +64,14 @@ public function getAccessToken(): ?array
return $this->getService()->getClient()->getAccessToken();
}

public function spreadsheet(string $spreadsheetId): static
public function spreadsheet(string $spreadsheetId): self
{
$this->spreadsheetId = $spreadsheetId;

return $this;
}

public function spreadsheetByTitle(string $title): static
public function spreadsheetByTitle(string $title): self
{
$list = $this->spreadsheetList();

Expand All @@ -80,14 +80,14 @@ public function spreadsheetByTitle(string $title): static
return $this;
}

public function sheet(string $sheet): static
public function sheet(string $sheet): self
{
$this->sheet = $sheet;

return $this;
}

public function sheetById(string $sheetId): static
public function sheetById(string $sheetId): self
{
$list = $this->sheetList();

Expand Down
4 changes: 2 additions & 2 deletions tests/SheetsDriveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function test_list()
$file,
];

$this->files->shouldReceive('listFiles->getFiles')->once()->andReturn($files);
$this->files->expects('listFiles->getFiles')->once()->andReturn($files);

$list = Sheets::spreadsheetList();

Expand All @@ -52,7 +52,7 @@ public function test_list()

public function test_null()
{
Google::shouldReceive('make')->andReturn($this->service);
Google::expects('make')->andReturn($this->service);

$drive = Sheets::setDriveService(null)->getDriveService();

Expand Down
39 changes: 19 additions & 20 deletions tests/SheetsMockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function test_sheets_all()
$valueRange->setValues([['test1' => '1'], ['test2' => '2']]);
$response->setValueRanges([$valueRange]);

$this->values->shouldReceive('batchGet')->with(m::any(), m::any())->once()->andReturn($response);
$this->values->expects('batchGet')->with(m::any(), m::any())->once()->andReturn($response);

$values = $this->sheet->spreadsheet('test')
->sheet('test')
Expand All @@ -75,7 +75,7 @@ public function test_sheets_empty()
$valueRange->setValues(null);
$response->setValueRanges([$valueRange]);

$this->values->shouldReceive('batchGet')->with(m::any(), m::any())->once()->andReturn($response);
$this->values->expects('batchGet')->with(m::any(), m::any())->once()->andReturn($response);

$values = $this->sheet->all();

Expand All @@ -89,7 +89,7 @@ public function test_sheets_get()
$valueRange->setValues([['test1' => '1'], ['test2' => '2']]);
$response->setValueRanges([$valueRange]);

$this->values->shouldReceive('batchGet')->with(m::any(), m::any())->once()->andReturn($response);
$this->values->expects('batchGet')->with(m::any(), m::any())->once()->andReturn($response);

$values = $this->sheet->get();

Expand All @@ -101,7 +101,7 @@ public function test_sheets_update()
{
$response = new BatchUpdateValuesResponse;

$this->values->shouldReceive('batchUpdate')->once()->andReturn($response);
$this->values->expects('batchUpdate')->once()->andReturn($response);

$values = $this->sheet->sheet('test')->range('A1')->update([['test']]);

Expand All @@ -116,7 +116,7 @@ public function test_sheets_first()
$valueRange->setValues([['test1' => '1'], ['test2' => '2']]);
$response->setValueRanges([$valueRange]);

$this->values->shouldReceive('batchGet')->with(m::any(), m::any())->once()->andReturn($response);
$this->values->expects('batchGet')->with(m::any(), m::any())->once()->andReturn($response);

$value = $this->sheet->first();

Expand All @@ -130,7 +130,7 @@ public function test_sheets_first_empty()
$valueRange->setValues(null);
$response->setValueRanges([$valueRange]);

$this->values->shouldReceive('batchGet')->with(m::any(), m::any())->once()->andReturn($response);
$this->values->expects('batchGet')->with(m::any(), m::any())->once()->andReturn($response);

$value = $this->sheet->first();

Expand All @@ -139,7 +139,7 @@ public function test_sheets_first_empty()

public function test_sheets_clear()
{
$this->values->shouldReceive('clear')->once();
$this->values->expects('clear')->once();

$value = $this->sheet->clear();

Expand All @@ -154,7 +154,7 @@ public function test_sheets_append()
$valueRange->setValues([['test1' => '1'], ['test2' => '2']]);
$response->setUpdates($updates);

$this->values->shouldReceive('append')->once()->andReturn($response);
$this->values->expects('append')->once()->andReturn($response);

$value = $this->sheet->append([[]]);

Expand All @@ -168,7 +168,7 @@ public function test_sheets_append_with_keys()
$valueRange->setValues([['header1', 'header2'], ['value1', 'value2']]);
$response->setValueRanges([$valueRange]);

$this->values->shouldReceive('batchGet')
$this->values->expects('batchGet')
->with(m::any(), m::any())
->andReturn($response);

Expand All @@ -178,7 +178,7 @@ public function test_sheets_append_with_keys()

public function test_spreadsheet_properties()
{
$this->spreadsheets->shouldReceive('get->getProperties->toSimpleObject')->once()->andReturn(new \stdClass);
$this->spreadsheets->expects('get->getProperties->toSimpleObject')->once()->andReturn(new \stdClass);

$properties = $this->sheet->spreadsheetProperties();

Expand All @@ -188,9 +188,9 @@ public function test_spreadsheet_properties()
public function test_sheet_properties()
{
$sheet = m::mock(Spreadsheet::class);
$sheet->shouldReceive('getProperties->toSimpleObject')->once()->andReturn(new \stdClass);
$sheet->expects('getProperties->toSimpleObject')->once()->andReturn(new \stdClass);

$this->spreadsheets->shouldReceive('get->getSheets')->once()->andReturn([$sheet]);
$this->spreadsheets->expects('get->getSheets')->once()->andReturn([$sheet]);

$properties = $this->sheet->sheetProperties();

Expand All @@ -213,7 +213,7 @@ public function test_sheets_list()
],
]);

$this->spreadsheets->shouldReceive('get->getSheets')->andReturn([$sheets]);
$this->spreadsheets->expects('get->getSheets')->andReturn([$sheets]);
$values = $this->sheet->sheetList();

$this->assertSame(['sheetId' => 'title'], $values);
Expand All @@ -230,7 +230,7 @@ public function test_sheet_by_id()

$sheet = m::mock(SheetsClient::class)->makePartial();

$sheet->shouldReceive('sheetList')->andReturn([$sheets]);
$sheet->expects('sheetList')->andReturn([$sheets]);

$sheet->sheetById('sheetId');

Expand All @@ -245,7 +245,7 @@ public function test_spreadsheet_by_title()

$sheet = m::mock(SheetsClient::class)->makePartial();

$sheet->shouldReceive('spreadsheetList')->andReturn($list);
$sheet->expects('spreadsheetList')->andReturn($list);

$sheet->spreadsheetByTitle('title');

Expand Down Expand Up @@ -278,7 +278,7 @@ public function test_get_client()
public function test_add_sheet()
{
$this->spreadsheets
->shouldReceive('batchUpdate')
->expects('batchUpdate')
->andReturn(new BatchUpdateSpreadsheetResponse);

$response = $this->sheet->addSheet('new sheet');
Expand All @@ -294,20 +294,19 @@ public function test_delete_sheet()
],
]);

$this->spreadsheets->shouldReceive('get->getSheets')->andReturn([$sheets]);
$this->spreadsheets->expects('get->getSheets')->andReturn([$sheets]);
$this->spreadsheets
->shouldReceive('batchUpdate')
->expects('batchUpdate')
->andReturn(new BatchUpdateSpreadsheetResponse);

$this->sheet->shouldReceive('sheetList')->andReturn([$sheets]);
$response = $this->sheet->deleteSheet('title');
$this->assertNotNull($response);
}

public function test_get_proper_ranges()
{
$this->values
->shouldReceive('batchUpdate')
->expects('batchUpdate')
->times(3)
->andReturn(new BatchUpdateValuesResponse);

Expand Down
Loading