@@ -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 }
0 commit comments