<?php

namespace Application\Service\Extension\Xml;

class BaseXmlGenerator
{
    protected function buildClinicalDataTag(array $tagAttributes = [])
    {
        return "ClinicalData {$this->buildTagAttributes($tagAttributes)}";
    }

    protected function buildSiteRefDataTag(array $tagAttributes = [])
    {
        return "SiteRef {$this->buildTagAttributes($tagAttributes)}";
    }

    protected function buildSubjectDataTag(array $tagAttributes = [])
    {
        return "SubjectData {$this->buildTagAttributes($tagAttributes)}";
    }

    protected function buildStudyEventDataTag(array $tagAttributes = [])
    {
        return "StudyEventData {$this->buildTagAttributes($tagAttributes)}";
    }

    protected function  buildFormDataDataTag(array $tagAttributes = [])
    {
        return "FormData {$this->buildTagAttributes($tagAttributes)}";
    }

    protected function  buildItemGroupDataTag(array $tagAttributes = [])
    {
        return "ItemGroupData {$this->buildTagAttributes($tagAttributes)}";
    }

    protected function buildTagAttributes(array $tagAttributes = [])
    {
        $tmp = [];
        foreach ($tagAttributes as $key => $attribute) {
            $tmp[] = sprintf("{{%s:=%s}}", $key, str_replace(PHP_EOL, '', $attribute));
        }

        return implode(' ', $tmp);
    }


}