255, // @todo Should be unique for each message ]; private const MAX_ELEMENTS = 5; private const VALID_ELEMENTS = [ Button::class, MultiStaticSelect::class, Blocks\Accessories\Overflow::class, ]; public function __construct() { parent::__construct(); // Defaults $this->type = 'actions'; } public static function item(): self { return new self(); } public function jsonSerialize() { if (! $this->elements) throw new Exception('Must define at least 1 element'); return parent::jsonSerialize(); } /* OPTIONAL ITEMS */ public function block_id(string $string): self { $this->block_id = $this->validate('block_id',$string); return $this; } public function elements(Collection $collection): self { if (count($collection) > self::MAX_ELEMENTS) throw new Exception(sprintf('Can only have maximum %d elements',self::MAX_ELEMENTS)); // @todo Check that a valid element is added. https://api.slack.com/reference/block-kit/blocks#actions $this->elements = $collection; return $this; } }