public function addData(array $data, $templates = null): self
    {
        if (null === $templates) {
            $this->sharedVariables = \array_merge($this->sharedVariables, $data);

            return $this;
        }

        if (\is_string($templates)) {
            $templates = [$templates];
        }

        if (\is_array($templates)) {
            foreach ($templates as $template) {
                if (isset($this->templateVariables[$template])) {
                    $this->templateVariables[$template] = \array_merge($this->templateVariables[$template], $data);
                } else {
                    $this->templateVariables[$template] = $data;
                }
            }

            return $this;
        }

        throw new \InvalidArgumentException(
            'The templates variable must be null, an array or a string, ' . \gettype($templates) . ' given.'
        );
    }