Skip to content

Commit 1a52591

Browse files
authored
Apply fixes from StyleCI (#101)
1 parent 4f06203 commit 1a52591

File tree

4 files changed

+23
-41
lines changed

4 files changed

+23
-41
lines changed

src/Console/Commands/MakeNotionModel.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class MakeNotionModel extends Command
3030
*/
3131
public function handle()
3232
{
33-
3433
$databaseId = $this->argument('database_id');
3534
$databaseName = $this->argument('database_name');
3635

@@ -39,10 +38,10 @@ public function handle()
3938
$this->info("Fetching structure of {$databaseId} database from Notion...");
4039

4140
$databaseStruct = $notion->databases()->find($databaseId);
42-
$phpDocsProperties = "";
43-
$visibleArray = "";
44-
$propertyTypeMape = "";
45-
$propertyTitleMap = "";
41+
$phpDocsProperties = '';
42+
$visibleArray = '';
43+
$propertyTypeMape = '';
44+
$propertyTitleMap = '';
4645

4746
if ($databaseName === null) {
4847
$databaseName = Str::singular(Str::studly(Str::slug($databaseStruct->getTitle(), '_')));
@@ -53,17 +52,15 @@ public function handle()
5352
$propType = $reflection->getReturnType() ?? 'mixed';
5453
$notionPropType = Str::studly(Str::slug($propertyInfo->getType(), '_'));
5554

56-
if ($reflection->getReturnType() !== null && !$propType->isBuiltin()) {
57-
$propType = '\\' . $propType->getName();
55+
if ($reflection->getReturnType() !== null && ! $propType->isBuiltin()) {
56+
$propType = '\\'.$propType->getName();
5857
}
5958

6059
$propName = Str::slug($propertyInfo->getTitle(), '_');
6160
$phpDocsProperties .= " * @property {$propType} \${$propName} $notionPropType \n";
6261
$visibleArray .= " '$propName',\n";
6362
}
6463

65-
66-
6764
$contents = "<?php
6865
namespace App\NotionModels;
6966
@@ -93,6 +90,7 @@ class {$databaseName} extends NotionModel
9390

9491
File::put("app/NotionModels/$databaseName.php", $contents);
9592
$this->info("Model for database {$this->argument('database_id')} has been created at 'app/NotionModels/$databaseName.php' .");
93+
9694
return 0;
9795
}
9896
}

src/LaravelNotionApiServiceProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function boot()
1717
{
1818
if ($this->app->runningInConsole()) {
1919
$this->publishes([
20-
__DIR__ . '/../config/config.php' => config_path('laravel-notion-api.php'),
20+
__DIR__.'/../config/config.php' => config_path('laravel-notion-api.php'),
2121
], 'config');
2222

2323
$this->commands([
@@ -32,7 +32,7 @@ public function boot()
3232
public function register()
3333
{
3434
// Automatically apply the package configuration
35-
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'laravel-notion-api');
35+
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'laravel-notion-api');
3636

3737
$this->app->singleton(Notion::class, function () {
3838
return new Notion(config('laravel-notion-api.notion-api-token'), config('laravel-notion-api.version'));

src/Models/NotionModel.php

+5-16
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,12 @@
22

33
namespace FiveamCode\LaravelNotionApi\Models;
44

5-
use FiveamCode\LaravelNotionApi\Endpoints\Database;
6-
use FiveamCode\LaravelNotionApi\Entities\Collections\PageCollection;
75
use FiveamCode\LaravelNotionApi\Entities\Page;
86
use FiveamCode\LaravelNotionApi\Exceptions\HandlingException;
9-
use Illuminate\Support\Collection;
107
use FiveamCode\LaravelNotionApi\Notion;
11-
use FiveamCode\LaravelNotionApi\Query\Filters\Filter;
12-
use FiveamCode\LaravelNotionApi\Query\Filters\Operators;
13-
use FiveamCode\LaravelNotionApi\Query\Sorting;
148
use FiveamCode\LaravelNotionApi\Query\StartCursor;
9+
use Illuminate\Support\Collection;
1510
use Illuminate\Support\Facades\Cache;
16-
use Illuminate\Support\Facades\Request;
17-
use Illuminate\Support\Str;
1811

1912
class NotionModel
2013
{
@@ -44,27 +37,26 @@ class NotionModel
4437
public static $cacheDurationInSeconds = 0;
4538

4639
/**
47-
* @var boolean
40+
* @var bool
4841
*/
4942
public static $convertPropsToText = false;
5043

5144
public $props;
5245

5346
public Page $page;
5447

55-
5648
public function __construct($databaseId = null)
5749
{
5850
if ($databaseId == null) {
5951
$databaseId = static::$databaseId;
6052
}
6153
}
6254

63-
public static function createInstance(){
55+
public static function createInstance()
56+
{
6457
return new static();
6558
}
6659

67-
6860
/**
6961
* @return string
7062
*/
@@ -77,7 +69,7 @@ public static function databaseId(): string
7769
}
7870

7971
/**
80-
* @return
72+
* @return
8173
*/
8274
public static function notionInstance(): Notion
8375
{
@@ -105,8 +97,6 @@ public static function all()
10597
return self::query()->get();
10698
}
10799

108-
109-
110100
/**
111101
* @return ?static
112102
*/
@@ -142,5 +132,4 @@ public static function getNextCursor(): ?string
142132
{
143133
return self::$nextCursor;
144134
}
145-
146135
}

src/Models/NotionQueryBuilder.php

+9-14
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
use FiveamCode\LaravelNotionApi\Endpoints\Database;
66
use FiveamCode\LaravelNotionApi\Entities\Collections\PageCollection;
77
use FiveamCode\LaravelNotionApi\Entities\Page;
8-
use FiveamCode\LaravelNotionApi\Exceptions\HandlingException;
9-
use Illuminate\Support\Collection;
10-
use FiveamCode\LaravelNotionApi\Notion;
118
use FiveamCode\LaravelNotionApi\Query\Filters\Filter;
129
use FiveamCode\LaravelNotionApi\Query\Filters\Operators;
1310
use FiveamCode\LaravelNotionApi\Query\StartCursor;
1411
use Illuminate\Support\Arr;
12+
use Illuminate\Support\Collection;
1513
use Illuminate\Support\Facades\Cache;
1614
use Illuminate\Support\Str;
1715

@@ -24,7 +22,6 @@ class NotionQueryBuilder
2422

2523
private $modelClass = null;
2624

27-
2825
public ?Database $endpoint = null;
2926
public ?Collection $filters = null;
3027
public ?Collection $sortings = null;
@@ -41,7 +38,8 @@ public function __construct($class)
4138
public function pluck($value, $key = null): Collection
4239
{
4340
$pageCollection = $this->internalQuery();
44-
return $pageCollection->pluck('props.' . $value, $key !== null ? 'props.' . $key : null);
41+
42+
return $pageCollection->pluck('props.'.$value, $key !== null ? 'props.'.$key : null);
4543
}
4644

4745
private function queryToNotion(int $limit = 100): PageCollection
@@ -110,7 +108,6 @@ public function get()
110108
return $this->internalQuery();
111109
}
112110

113-
114111
/**
115112
* @return string
116113
*/
@@ -132,23 +129,24 @@ public function getAllAsJson()
132129
public function propsToText()
133130
{
134131
$this->localConvertPropsToText = true;
132+
135133
return $this;
136134
}
137135

138-
139136
public function offset($offset)
140137
{
141138
$this->endpoint->offset($offset);
139+
142140
return $this;
143141
}
144142

145143
public function limit($offset)
146144
{
147145
$this->endpoint->limit($offset);
146+
148147
return $this;
149148
}
150149

151-
152150
public function orderBy($property, $direction = 'asc')
153151
{
154152
if ($this->sortings == null) {
@@ -218,7 +216,7 @@ public function where($property, $operator, $value = null)
218216
$this->filters->add(
219217
Filter::textFilter($property, $operator, $value)
220218
);
221-
} else if (is_numeric($value)) {
219+
} elseif (is_numeric($value)) {
222220
$this->filters->add(
223221
Filter::numberFilter($property, $operator, $value)
224222
);
@@ -231,8 +229,6 @@ public function where($property, $operator, $value = null)
231229
return $this;
232230
}
233231

234-
235-
236232
public function paginate($pageSize = 100)
237233
{
238234
$this->endpoint->limit($pageSize);
@@ -244,7 +240,6 @@ public function paginate($pageSize = 100)
244240

245241
$result = $this->internalQuery();
246242

247-
248243
return [
249244
'per_page' => $pageSize,
250245
'next_cursor' => $result->getRawNextCursor(),
@@ -262,9 +257,9 @@ private function cacheKey(): string
262257
{
263258
$postCacheKey = '';
264259
if ($this->nextCursor !== null) {
265-
$postCacheKey = '-' . $this->nextCursor->__toString();
260+
$postCacheKey = '-'.$this->nextCursor->__toString();
266261
}
267262

268-
return $this->modelClass::$preCacheKey . $this->modelClass::$databaseId . $postCacheKey;
263+
return $this->modelClass::$preCacheKey.$this->modelClass::$databaseId.$postCacheKey;
269264
}
270265
}

0 commit comments

Comments
 (0)