Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Feb 6, 2024
1 parent b368074 commit 3b30028
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
10 changes: 6 additions & 4 deletions src/Endpoints/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ public function __construct(Notion $notion, string $pageId)
public function property(string $propertyId): Property|EntityCollection
{
$response = $this->get(
$this->url(Endpoint::PAGES . '/' . $this->pageId . '/' . 'properties' . '/' . rawurlencode(rawurldecode($propertyId)))
$this->url(Endpoint::PAGES.'/'.$this->pageId.'/'.'properties'.'/'.rawurlencode(rawurldecode($propertyId)))
);

$rawContent = $response->json();

if($rawContent['object'] === 'list'){
if(count($rawContent['results']) === 0) return new EntityCollection();
if ($rawContent['object'] === 'list') {
if (count($rawContent['results']) === 0) {
return new EntityCollection();
}

$type = $rawContent['results'][0]['type'];

return match($type){
return match ($type) {
'people' => new UserCollection($rawContent),
default => new EntityCollection($rawContent)
};
Expand Down
3 changes: 1 addition & 2 deletions src/Entities/Collections/UserCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ protected function collectChildren(): void
{
$this->collection = new Collection();
foreach ($this->rawResults as $userChild) {

//TODO: create a new type for 'people' (outer layer for user)
if($userChild['type'] === 'people') {
if ($userChild['type'] === 'people') {
$userChild = $userChild['people'];
}

Expand Down
8 changes: 5 additions & 3 deletions src/Entities/Properties/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __construct(string $title = null)
*/
protected function setResponseData(array $responseData): void
{
if (!Arr::exists($responseData, 'id')) {
if (! Arr::exists($responseData, 'id')) {
throw HandlingException::instance('invalid json-array for property: no id provided');
}
$this->responseData = $responseData;
Expand All @@ -88,7 +88,7 @@ protected function setResponseData(array $responseData): void
*/
protected function setObjectResponseData(array $responseData): void
{
if (!Arr::exists($responseData, 'object') || !Arr::exists($responseData, 'id')) {
if (! Arr::exists($responseData, 'object') || ! Arr::exists($responseData, 'id')) {
throw HandlingException::instance('invalid json-array for property: no object or id provided');
}
$this->responseData = $responseData;
Expand All @@ -112,12 +112,14 @@ private function fillContent(): void
if (Arr::exists($this->responseData, $this->getType())) {
$this->rawContent = $this->responseData[$this->getType()];
$this->content = $this->rawContent;

return;
}

if (Arr::exists($this->responseData, 'object') && Arr::exists($this->responseData, $this->getObjectType())) {
$this->rawContent = $this->responseData[$this->getObjectType()];
$this->content = $this->rawContent;

return;
}
}
Expand Down Expand Up @@ -264,7 +266,7 @@ private static function mapTypeToClass(string $type): string
case 'relation':
$class = str_replace('_', '', ucwords($type, '_'));

return 'FiveamCode\\LaravelNotionApi\\Entities\\Properties\\' . $class;
return 'FiveamCode\\LaravelNotionApi\\Entities\\Properties\\'.$class;
case 'text':
case 'rich_text':
// TODO: Depending on the Notion API version.
Expand Down
4 changes: 0 additions & 4 deletions tests/RecordedEndpointPageTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?php

use Carbon\Carbon;
use FiveamCode\LaravelNotionApi\Entities\Collections\CommentCollection;
use FiveamCode\LaravelNotionApi\Entities\Collections\EntityCollection;
use FiveamCode\LaravelNotionApi\Entities\Comment;
use FiveamCode\LaravelNotionApi\Entities\Entity;
use FiveamCode\LaravelNotionApi\Entities\Properties\Property;
use Illuminate\Support\Facades\Http;

Expand Down

0 comments on commit 3b30028

Please sign in to comment.