Skip to content

Commit bb3d2f1

Browse files
MaestroErrorgithub-actions[bot]
authored andcommitted
Fix styling
1 parent 73d56cb commit bb3d2f1

File tree

5 files changed

+27
-42
lines changed

5 files changed

+27
-42
lines changed

src/Adapters/BaseBlockAdapter.php

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@ abstract class BaseBlockAdapter implements BlockAdapterInterface
88
{
99
/**
1010
* The Notion block type this adapter handles
11-
*
12-
* @var string
1311
*/
1412
protected string $type;
1513

1614
/**
1715
* The blade template path for rendering markdown
18-
*
19-
* @var string
2016
*/
2117
protected string $template;
2218

@@ -31,22 +27,18 @@ public function __construct()
3127

3228
/**
3329
* Get the Notion block type this adapter handles
34-
*
35-
* @return string
3630
*/
3731
abstract public function getType(): string;
3832

3933
/**
4034
* Get the blade template path for rendering markdown
41-
*
42-
* @return string
4335
*/
4436
abstract public function getTemplate(): string;
4537

4638
/**
4739
* Convert a Notion block to Markdown format
4840
*
49-
* @param array $block The Notion block data
41+
* @param array $block The Notion block data
5042
* @return string The markdown representation
5143
*/
5244
public function toMarkdown(array $block): string
@@ -56,15 +48,14 @@ public function toMarkdown(array $block): string
5648
}
5749

5850
$data = $this->prepareData($block);
59-
51+
6052
return trim(View::make($this->template, $data)->render());
6153
}
6254

6355
/**
6456
* Prepare data for the template
6557
*
66-
* @param array $block The Notion block data
67-
* @return array
58+
* @param array $block The Notion block data
6859
*/
6960
protected function prepareData(array $block): array
7061
{
@@ -77,9 +68,8 @@ protected function prepareData(array $block): array
7768
/**
7869
* Process text annotations and convert to markdown
7970
*
80-
* @param array $annotations Text annotations from Notion
81-
* @param string $text The text content
82-
* @return string
71+
* @param array $annotations Text annotations from Notion
72+
* @param string $text The text content
8373
*/
8474
protected function processAnnotations(array $annotations, string $text): string
8575
{
@@ -98,44 +88,43 @@ protected function processAnnotations(array $annotations, string $text): string
9888
if ($annotations['underline']) {
9989
$text = "<u>{$text}</u>";
10090
}
101-
91+
10292
return $text;
10393
}
10494

10595
/**
10696
* Process rich text blocks from Notion
10797
*
108-
* @param \RedberryProducts\MdNotion\DTOs\RichTextDTO[] $richText Array of rich text DTOs
109-
* @return string
98+
* @param \RedberryProducts\MdNotion\DTOs\RichTextDTO[] $richText Array of rich text DTOs
11099
*/
111100
protected function processRichText(array $richText): string
112101
{
113102
$result = '';
114-
103+
115104
foreach ($richText as $textBlock) {
116105
$text = trim($textBlock->plainText);
117106

118107
if ($textBlock->href) {
119108
$text = "[$text]({$textBlock->href})";
120109
}
121-
110+
122111
$text = $this->processAnnotations($textBlock->annotations, $text);
123-
$result .= " " . $text;
112+
$result .= ' '.$text;
124113
}
125-
114+
126115
return $result;
127116
}
128117

129118
/**
130119
* Get the content from a block's text property
131120
*
132-
* @param array $block The Notion block
133-
* @return string
121+
* @param array $block The Notion block
134122
*/
135123
protected function getBlockContent(array $block): string
136124
{
137125
$blockType = $block['type'];
138-
return isset($block[$blockType]['rich_text'])
126+
127+
return isset($block[$blockType]['rich_text'])
139128
? $this->processRichText($block[$blockType]['rich_text'])
140129
: '';
141130
}

src/Adapters/BlockAdapterInterface.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,18 @@ interface BlockAdapterInterface
77
/**
88
* Convert a Notion block to Markdown format
99
*
10-
* @param array $block The Notion block data
10+
* @param array $block The Notion block data
1111
* @return string The markdown representation
1212
*/
1313
public function toMarkdown(array $block): string;
1414

1515
/**
1616
* Get the Notion block type this adapter handles
17-
*
18-
* @return string
1917
*/
2018
public function getType(): string;
2119

2220
/**
2321
* Get the blade template path for rendering markdown
24-
*
25-
* @return string
2622
*/
2723
public function getTemplate(): string;
2824
}

src/DTOs/BlockDTO.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(array $block)
2727
$this->id = $block['id'];
2828
$this->type = $block['type'];
2929
$this->hasChildren = $block['has_children'] ?? false;
30-
30+
3131
$this->fromArray($block[$this->type]);
3232
}
3333

src/DTOs/RichTextDTO.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(array $richText)
4545
/**
4646
* Create a collection of RichTextDTO from an array of rich text
4747
*
48-
* @param array $richTextArray Array of rich text from Notion API
48+
* @param array $richTextArray Array of rich text from Notion API
4949
* @return RichTextDTO[]
5050
*/
5151
public static function collection(array $richTextArray): array

tests/Adapters/ParagraphAdapterTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,42 @@
1414
'type' => 'text',
1515
'text' => [
1616
'content' => 'Hello ',
17-
'link' => null
17+
'link' => null,
1818
],
1919
'annotations' => [
2020
'bold' => true,
2121
'italic' => false,
2222
'strikethrough' => false,
2323
'underline' => false,
2424
'code' => false,
25-
'color' => 'default'
25+
'color' => 'default',
2626
],
2727
'plain_text' => 'Hello ',
28-
'href' => null
28+
'href' => null,
2929
],
3030
[
3131
'type' => 'text',
3232
'text' => [
3333
'content' => 'world',
34-
'link' => ['url' => 'https://example.com']
34+
'link' => ['url' => 'https://example.com'],
3535
],
3636
'annotations' => [
3737
'bold' => false,
3838
'italic' => false,
3939
'strikethrough' => false,
4040
'underline' => false,
4141
'code' => false,
42-
'color' => 'default'
42+
'color' => 'default',
4343
],
4444
'plain_text' => 'world',
45-
'href' => 'https://example.com'
46-
]
45+
'href' => 'https://example.com',
46+
],
4747
],
48-
'color' => 'default'
49-
]
48+
'color' => 'default',
49+
],
5050
];
5151

52-
$adapter = new ParagraphAdapter();
52+
$adapter = new ParagraphAdapter;
5353
$markdown = $adapter->toMarkdown($block);
5454

5555
expect($markdown)->toBe('**Hello** [world](https://example.com)');

0 commit comments

Comments
 (0)