protected function addAttributes(\DOMElement $element, ItemFieldInterface $field, ItemInterface $item = null)
    {
        foreach ($field->getAttributes() as $key => $value) {
            if ($item) {
                $key = method_exists($item, $key) ? call_user_func([$item, $key]) : $key;
                $value = method_exists($item, $value) ? call_user_func([$item, $value]) : $value;
            }

            $element->setAttribute($key, $value);
        }
    }