public function map(array $organisationElements)
 {
     $organisations = [];
     foreach ($organisationElements as $organisationElement) {
         $organisation = new Organization();
         $organisation->setIdentifier(Marshaller::getDOMElementAttributeAs($organisationElement, 'identifier'));
         $organisation->setStructure(Marshaller::getDOMElementAttributeAs($organisationElement, 'structure'));
         $titleElements = Marshaller::getChildElementsByTagName($organisationElement, 'title');
         if (count($titleElements) >= 1) {
             $organisation->setTitle($titleElements[0]->nodeValue);
         }
         $itemElements = Marshaller::getChildElementsByTagName($organisationElement, 'item');
         $items = [];
         foreach ($itemElements as $itemElement) {
             $item = new Item();
             $item->setTitle(Marshaller::getChildElementsByTagName($itemElement, 'title'));
             $item->setIdentifier(Marshaller::getDOMElementAttributeAs($itemElement, 'identifier'));
             $item->setIdentifierref(Marshaller::getDOMElementAttributeAs($itemElement, 'identifierref'));
             $item->setIsvisible(Marshaller::getDOMElementAttributeAs($itemElement, 'isvisible'));
             $items[] = $item;
         }
         $organisation->setItems($items);
         $organisations[] = $organisation;
     }
     return $organisations;
 }
 /**
  * Parse an array of DOMElement to array of Dependency models
  *
  * @param [DOMElement]  $dependencyListElements
  * @return array
  */
 public function mapDependencyElements(array $dependencyListElements)
 {
     $dependencies = [];
     if (is_array($dependencyListElements)) {
         foreach ($dependencyListElements as $dependencyElement) {
             $dependency = new Dependency();
             $dependency->setIdentifierref(Marshaller::getDOMElementAttributeAs($dependencyElement, 'identifierref'));
             $dependencies[] = $dependency;
         }
     }
     return $dependencies;
 }
 public function parseManifestElement(\DOMElement $rootElement)
 {
     // Manifest mapping start!
     $manifest = new Manifest();
     $manifest->setIdentifier(Marshaller::getDOMElementAttributeAs($rootElement, 'identifier'));
     // Mapping <resource>(s) to Resource model
     $resourcesElement = Marshaller::getChildElementsByTagName($rootElement, 'resources');
     if (!empty($resourcesElement)) {
         if (count($resourcesElement) !== 1) {
             throw new MappingException('Resources tag must occur once');
         }
         $resourceMapper = new ResourcesMapper();
         $resourcesListElements = Marshaller::getChildElementsByTagName($resourcesElement[0], 'resource');
         $resources = $resourceMapper->map($resourcesListElements);
         $manifest->setResources($resources);
     }
     // Mapping <organisation>(s) to Organisation model
     $organizationElements = Marshaller::getChildElementsByTagName($rootElement, 'organizations');
     if (!empty($organizationElements)) {
         if (count($organizationElements) !== 1) {
             throw new MappingException('Organisations tag must occur once');
         }
         $organisationsMapper = new OrganizationsMapper();
         $organisationListElements = Marshaller::getChildElementsByTagName($organizationElements[0], 'organization');
         $organisations = $organisationsMapper->map($organisationListElements);
         $manifest->setOrganizations($organisations);
     }
     // Mapping package Metadata
     $metadataElement = Marshaller::getChildElementsByTagName($rootElement, 'metadata');
     if (!empty($metadataElement)) {
         if (count($metadataElement) !== 1) {
             throw new MappingException('Metadata tag must occur once');
         }
         $metadataMapper = new MetadataMapper();
         $manifest->setMetadata($metadataMapper->map($metadataElement[0]));
     }
     // Mapping sub-manifest
     $subManifestElement = Marshaller::getChildElementsByTagName($rootElement, 'manifest');
     if (!empty($subManifestElement)) {
         if (count($subManifestElement) !== 1) {
             throw new MappingException('Manifest tag must occur once');
         }
         $manifest->setManifest($this->parseManifestElement($subManifestElement[0]));
     }
     return $manifest;
 }