43 lines
795 B
PHP
43 lines
795 B
PHP
<?php
|
|
|
|
namespace Slack\Blockkit\Blocks;
|
|
|
|
use Slack\Blockkit\Blocks;
|
|
use Slack\Blockkit\Blocks\Elements\Text;
|
|
use Slack\Exceptions\SlackSyntaxException;
|
|
|
|
final class Header extends Blocks
|
|
{
|
|
protected const LIMITS = [
|
|
'block_id' => 255, // @todo Should be unique for each message
|
|
'text' => 150,
|
|
];
|
|
|
|
/**
|
|
* @param string $text
|
|
* @throws SlackSyntaxException
|
|
*/
|
|
public function __construct(string $text)
|
|
{
|
|
parent::__construct();
|
|
|
|
// Defaults
|
|
$this->type = 'header';
|
|
|
|
$this->text = Text::item($this->validate('text',$text),'plain_text');
|
|
}
|
|
|
|
public static function item(string $text): self
|
|
{
|
|
return new self($text);
|
|
}
|
|
|
|
/* OPTIONAL ITEMS */
|
|
|
|
public function block_id(string $string): self
|
|
{
|
|
$this->block_id = $this->validate('block_id',$string);
|
|
|
|
return $this;
|
|
}
|
|
} |