Fix logic

This commit is contained in:
Fabien Potencier 2020-06-25 10:39:34 +02:00
parent 213c6ab6d5
commit 7bac792328

View File

@ -39,16 +39,15 @@ final class SlackSectionBlock extends AbstractSlackBlock
*/ */
public function field(string $text, bool $markdown = true): self public function field(string $text, bool $markdown = true): self
{ {
if (10 === \count($this->options['fields'])) {
throw new \LogicException('Maximum number of fields should not exceed 10.');
}
$this->options['fields'][] = [ $this->options['fields'][] = [
'type' => $markdown ? 'mrkdwn' : 'plain_text', 'type' => $markdown ? 'mrkdwn' : 'plain_text',
'text' => $text, 'text' => $text,
]; ];
// Maximum number of items is 10
if (10 <= \count($this->options['fields'])) {
throw new \LogicException('Maximum number of fields should not exceed 10.');
}
return $this; return $this;
} }