Skip to content

Commit e622b41

Browse files
committed
polish implementations
- rename "BaseBlockEntity" to "BlockEntity" in BlockEndpoint for clearity - mark createFileBlock method in BaseFileBlock as final - replace array_push with array[] = [...] for better performance
1 parent 76a4298 commit e622b41

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Endpoints/Block.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use FiveamCode\LaravelNotionApi\Exceptions\NotionException;
77
use FiveamCode\LaravelNotionApi\Exceptions\HandlingException;
88
use FiveamCode\LaravelNotionApi\Entities\Collections\BlockCollection;
9-
use FiveamCode\LaravelNotionApi\Entities\Blocks\Block as BaseBlockEntity;
9+
use FiveamCode\LaravelNotionApi\Entities\Blocks\Block as BlockEntity;
1010

1111
/**
1212
* Class Block
@@ -58,19 +58,19 @@ public function children(): BlockCollection
5858
* @return FiveamCode\LaravelNotionApi\Entities\Blocks\Block
5959
* @throws HandlingException
6060
*/
61-
public function append(array|BaseBlockEntity $appendices): BaseBlockEntity
61+
public function append(array|BlockEntity $appendices): BlockEntity
6262
{
6363
if (!is_array($appendices)) {
6464
$appendices = [$appendices];
6565
}
6666
$children = [];
6767

6868
foreach ($appendices as $block) {
69-
array_push($children, [
69+
$children[] = [
7070
"object" => "block",
7171
"type" => $block->getType(),
7272
$block->getType() => $block->getRawContent()
73-
]);
73+
];
7474
}
7575

7676
$body = [
@@ -82,6 +82,6 @@ public function append(array|BaseBlockEntity $appendices): BaseBlockEntity
8282
$body
8383
);
8484

85-
return new BaseBlockEntity($response->json());
85+
return new BlockEntity($response->json());
8686
}
8787
}

src/Entities/Blocks/BaseFileBlock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
class BaseFileBlock extends Block implements Modifiable
1717
{
18-
protected static function createFileBlock(BaseFileBlock $fileBlock, string $url, string $caption = ""): BaseFileBlock
18+
protected static final function createFileBlock(BaseFileBlock $fileBlock, string $url, string $caption = ""): BaseFileBlock
1919
{
2020
$fileBlock->rawContent = [
2121
'type' => 'external',

src/Entities/Blocks/TextBlock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ protected static function createTextBlock(TextBlock $textBlock, array|string $te
2323

2424
$text = [];
2525
foreach ($textContent as $textItem) {
26-
array_push($text, [
26+
$text[] = [
2727
"type" => "text",
2828
"text" => [
2929
"content" => $textItem
3030
]
31-
]);
31+
];
3232
}
3333

3434
$textBlock->rawContent = [

0 commit comments

Comments
 (0)