diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 8505495..cef3ad0 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -1,4 +1,4 @@ -name: PHP Composer +name: Run Tests on: push: diff --git a/src/APIClient.php b/src/APIClient.php index a62eda7..c2a64c0 100644 --- a/src/APIClient.php +++ b/src/APIClient.php @@ -9,7 +9,6 @@ */ class APIClient { - protected const BASE_URL = "https://api.smartsheet.com/2.0/"; protected GuzzleClient $guzzleClient; diff --git a/src/Resources/Resource.php b/src/Resources/Resource.php index bc92f80..a616b62 100644 --- a/src/Resources/Resource.php +++ b/src/Resources/Resource.php @@ -4,7 +4,6 @@ class Resource { - protected array $data; public function __construct(array $data = []) diff --git a/src/Resources/Row.php b/src/Resources/Row.php index fe8fe51..8349dca 100644 --- a/src/Resources/Row.php +++ b/src/Resources/Row.php @@ -2,7 +2,6 @@ namespace Smartsheet\Resources; -use GuzzleHttp\Psr7\Response; use Smartsheet\SmartsheetClient; use Illuminate\Support\Collection; diff --git a/src/Resources/Sheet.php b/src/Resources/Sheet.php index fb7f368..6a894d2 100644 --- a/src/Resources/Sheet.php +++ b/src/Resources/Sheet.php @@ -8,7 +8,6 @@ class Sheet extends Resource { - protected SmartsheetClient $client; protected string $id; @@ -66,9 +65,10 @@ public function copyRowsTo(array $rowIds, string $sheetId) public function getRows(): Collection { - return collect($this->rows)->map(function ($row) { - return new Row($this->client, (array) $row, $this); - }); + return collect($this->rows) + ->map(function ($row) { + return new Row($this->client, (array) $row, $this); + }); } /** @@ -78,7 +78,6 @@ public function getRows(): Collection */ public function getColumnId($title): string { - $column = collect($this->columns) ->first(function ($col) use ($title) { return $col->title == $title; diff --git a/src/Resources/Workspace.php b/src/Resources/Workspace.php index e16e09b..4ca7739 100644 --- a/src/Resources/Workspace.php +++ b/src/Resources/Workspace.php @@ -21,6 +21,11 @@ class Workspace extends Resource protected string $name; protected array $sheets = []; + /** + * Workspace constructor. + * @param SmartsheetClient $client + * @param $data + */ public function __construct(SmartsheetClient $client, $data) { parent::__construct($data); @@ -44,6 +49,17 @@ public function createSheet($name, $columns = DEFAULT_COLUMNS): mixed ]); } + /** + * Fetches the sheet if it exists + * @param string $name + * @return Sheet $sheet + * @throws Exception + */ + public function getSheet(string $name): Sheet + { + return $this->client->getSheet($this->getSheetId($name)); + } + /** * @return array */ @@ -72,20 +88,6 @@ public function getSheetId(string $name): string return $sheet->id; } - /** - * Fetches the sheet if it exists - * @param string $name - * @return Sheet $sheet - * @throws Exception - */ - public function getSheet(string $name): Sheet - { - return $this->client->getSheet($this->getSheetId($name)); - } - - /** - * @return string - */ public function getId(): string { return $this->id; @@ -95,4 +97,5 @@ public function getName(): string { return $this->name; } + } diff --git a/src/SmartsheetClient.php b/src/SmartsheetClient.php index bb1fdec..b580d5a 100644 --- a/src/SmartsheetClient.php +++ b/src/SmartsheetClient.php @@ -16,11 +16,12 @@ public function __construct(array $config = []) parent::__construct($config); } - protected function instantiateCollection(string $class, array $target): Collection { + protected function instantiateCollection(string $class, array $target): Collection + { $temp = collect([]); - foreach($target as $t) { - $temp->add(new $class($this, (array) $t)); + foreach ($target as $t) { + $temp->add(new $class($this, (array)$t)); } return $temp; @@ -65,7 +66,7 @@ public function getSheet(string $sheetId): Sheet { $response = $this->get("sheets/$sheetId"); - return new Sheet($this, (array) $response); + return new Sheet($this, (array)$response); } /** @@ -84,6 +85,7 @@ public function getRow(string $sheetId, string $rowId): Row /** * Fetch a folder with a given ID + * * @param string $folderId * @return Folder */ @@ -94,6 +96,7 @@ public function getFolder(string $folderId): Folder /** * Fetch a workspace with a given ID + * * @param string $workspaceId * @return Workspace */