Skip to content

Commit

Permalink
Add type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
alies-dev committed Dec 6, 2021
1 parent f242b21 commit 7b14476
Showing 1 changed file with 11 additions and 44 deletions.
55 changes: 11 additions & 44 deletions src/HtmlCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ class HtmlCard extends Card
{
/**
* The width of the card (1/3, 1/2, or full).
*
* @var string
*/
public $width = '1/3';

/**
* Create a new element.
*
* @param string|null $component
*/
public function __construct($component = null)
Expand All @@ -37,26 +35,14 @@ public function component()
return 'html-card';
}

/**
* Set HTML code to display in a card
*
* @param string $htmlContent
*
* @return HtmlCard
*/
public function html(string $htmlContent)
/** Set HTML code to display in a card. */
public function html(string $htmlContent): static
{
return $this->withMeta(['content' => $htmlContent]);
}

/**
* Set Markdown code to display in a card (converted into HTML)
*
* @param string $htmlContent
*
* @return HtmlCard
*/
public function markdown(string $markdownContent)
/** Set Markdown code to display in a card (converted into HTML). */
public function markdown(string $markdownContent): static
{
$htmlContent = App::make(MarkdownConverter::class)::parse($markdownContent)->toHtml();

Expand All @@ -65,27 +51,18 @@ public function markdown(string $markdownContent)

/**
* Use blade view file to render Card content.
*
* @param string $view
* @param array $viewData
*
* @return HtmlCard
* @param array<string, mixed> $viewData
*/
public function view(string $view, array $viewData = [])
public function view(string $view, array $viewData = []): static
{
$htmlContent = view($view, $viewData)->render();

return $this->html($htmlContent);
}

/**
* Center card's content
*
* @param bool $centerContent
*
* @return HtmlCard
*/
public function center(bool $centerContent = true)
/** Center card's content. */
public function center(bool $centerContent = true): static
{
return $this->withMeta(['center' => $centerContent]);
}
Expand All @@ -96,24 +73,14 @@ public function center(bool $centerContent = true)
* full-width cards at the bottom. If you want to display full-width cards
* not at the end, you should use with=1/3 or 2/3 and this method.
* @see https://github.com/laravel/nova-issues/issues/1895#issuecomment-543684472
*
* @param bool $forceFullWidth
*
* @return HtmlCard
*/
public function forceFullWidth(bool $forceFullWidth = true)
public function forceFullWidth(bool $forceFullWidth = true): static
{
return $this->withMeta(['forceFullWidth' => $forceFullWidth]);
}

/**
* Whether to use standard Nova Card styles for a card (background, padding, etc)
*
* @param bool $withoutStyles
*
* @return HtmlCard
*/
public function withoutCardStyles(bool $withoutStyles = true)
/** Whether to use standard Nova Card styles for a card (background, padding, etc). */
public function withoutCardStyles(bool $withoutStyles = true): static
{
return $this->withMeta(['withoutCardStyles' => $withoutStyles]);
}
Expand Down

0 comments on commit 7b14476

Please sign in to comment.