File tree Expand file tree Collapse file tree 14 files changed +74
-13
lines changed
Expand file tree Collapse file tree 14 files changed +74
-13
lines changed Original file line number Diff line number Diff line change @@ -78,8 +78,12 @@ public function children(): BlockCollection
7878 * @return FiveamCode\LaravelNotionApi\Entities\Blocks\Block
7979 * @throws HandlingException
8080 */
81- public function append (array | BlockEntity $ appendices ): BlockEntity
81+ public function append ($ appendices ): BlockEntity
8282 {
83+ if (!is_array ($ appendices ) && !$ appendices instanceof BlockEntity) {
84+ throw new HandlingException ('$appendices must be an array or instance of BlockEntity ' );
85+ }
86+
8387 if (!is_array ($ appendices )) {
8488 $ appendices = [$ appendices ];
8589 }
Original file line number Diff line number Diff line change @@ -224,4 +224,10 @@ private static function mapTypeToClass(string $type): string
224224 return Block::class;
225225 }
226226 }
227+
228+ protected static function assertValidTextContent ($ textContent ) {
229+ if (!is_array ($ textContent ) && !is_string ($ textContent )) {
230+ throw new HandlingException ('$textContent content must be a string. ' );
231+ }
232+ }
227233}
Original file line number Diff line number Diff line change 88 */
99class BulletedListItem extends TextBlock
1010{
11- public static function create (array | string $ textContent ): BulletedListItem
11+ public static function create ($ textContent ): BulletedListItem
1212 {
13+ self ::assertValidTextContent ($ textContent );
14+
1315 $ bulletedListItem = new BulletedListItem ();
1416 TextBlock::createTextBlock ($ bulletedListItem , $ textContent );
1517 return $ bulletedListItem ;
Original file line number Diff line number Diff line change 88 */
99class HeadingOne extends TextBlock
1010{
11- public static function create (array | string $ textContent ): HeadingOne
11+ public static function create ($ textContent ): HeadingOne
1212 {
13+ self ::assertValidTextContent ($ textContent );
14+
1315 $ headingOne = new HeadingOne ();
1416 TextBlock::createTextBlock ($ headingOne , $ textContent );
1517 return $ headingOne ;
Original file line number Diff line number Diff line change 88 */
99class HeadingThree extends TextBlock
1010{
11- public static function create (array | string $ textContent ): HeadingThree
11+ public static function create ($ textContent ): HeadingThree
1212 {
13+ self ::assertValidTextContent ($ textContent );
14+
1315 $ headingThree = new HeadingThree ();
1416 HeadingThree::createTextBlock ($ headingThree , $ textContent );
1517 return $ headingThree ;
Original file line number Diff line number Diff line change 88 */
99class HeadingTwo extends TextBlock
1010{
11- public static function create (array | string $ textContent ): HeadingTwo
11+ public static function create ($ textContent ): HeadingTwo
1212 {
13+ self ::assertValidTextContent ($ textContent );
14+
1315 $ headingTwo = new HeadingTwo ();
1416 HeadingTwo::createTextBlock ($ headingTwo , $ textContent );
1517 return $ headingTwo ;
Original file line number Diff line number Diff line change 88 */
99class NumberedListItem extends TextBlock
1010{
11- public static function create (array | string $ textContent ): NumberedListItem
11+ public static function create ($ textContent ): NumberedListItem
1212 {
13+ self ::assertValidTextContent ($ textContent );
14+
1315 $ numberedListItem = new NumberedListItem ();
1416 TextBlock::createTextBlock ($ numberedListItem , $ textContent );
1517 return $ numberedListItem ;
Original file line number Diff line number Diff line change 88 */
99class Paragraph extends TextBlock
1010{
11- public static function create (array | string $ textContent ): Paragraph
11+ public static function create ($ textContent ): Paragraph
1212 {
13+ self ::assertValidTextContent ($ textContent );
14+
1315 $ paragraph = new Paragraph ();
1416 TextBlock::createTextBlock ($ paragraph , $ textContent );
1517 return $ paragraph ;
Original file line number Diff line number Diff line change 1111 */
1212class TextBlock extends Block implements Modifiable
1313{
14- protected static function createTextBlock (TextBlock $ textBlock , array | string $ textContent ): TextBlock
14+ protected static function createTextBlock (TextBlock $ textBlock , $ textContent ): TextBlock
1515 {
16+ self ::assertValidTextContent ($ textContent );
17+
1618 if (is_string ($ textContent )) {
1719 $ textContent = [$ textContent ];
1820 }
Original file line number Diff line number Diff line change 88 */
99class ToDo extends TextBlock
1010{
11- public static function create (array | string $ textContent ): ToDo
11+ public static function create ($ textContent ): ToDo
1212 {
13+ self ::assertValidTextContent ($ textContent );
14+
1315 $ toDo = new ToDo ();
1416 TextBlock::createTextBlock ($ toDo , $ textContent );
1517 return $ toDo ;
You can’t perform that action at this time.
0 commit comments