self::MAX_CHARS ) { continue; } if ( in_array( mb_strtolower( $option ), array_map( 'mb_strtolower', $clean ), true ) ) { continue; } $clean[] = $option; } $clean = array_slice( $clean, 0, self::MAX_OPTIONS ); return count( $clean ) >= 2 ? $clean : []; } /** * Execute the tool * * @param string|null $options Answers separated by |. * @return array */ public function __invoke( ?string $options = null ): array { $clean = self::clean_options( explode( '|', (string) $options ) ); if ( ! $clean ) { return [ 'ok' => false, 'error' => 'Give 2 to 4 short answers separated by |.', ]; } $this->card = [ 'card' => 'quick_replies', 'data' => [ 'options' => $clean ], ]; return [ 'ok' => true ]; } /** * Take the card left by the last run. * * @return array|null */ public function take_card(): ?array { $card = $this->card; $this->card = null; return $card; } }