1<?php 2 3namespace FINDOLOGIC\Export\Helpers; 4 5/** 6 * Class UsergroupAwareMultiValueItem 7 * @package FINDOLOGIC\Export\Helpers 8 * 9 * Single value for a UsergroupAwareMultiValue. 10 * 11 * When inheriting, make sure that the child class' constructor exposes $value and $usergroup, and calls the parent's 12 * constructor with those values, plus the name of the XML element in which the value is wrapped. 13 */ 14abstract class UsergroupAwareMultiValueItem implements Serializable 15{ 16 private $itemName; 17 private $value; 18 private $usergroup; 19 20 /** 21 * @SuppressWarnings(PHPMD.StaticAccess) 22 */ 23 public function __construct($itemName, $value, $usergroup) 24 { 25 $this->value = DataHelper::checkForEmptyValue($value); 26 $this->itemName = $itemName; 27 $this->usergroup = $usergroup; 28 } 29 30 public function getUsergroup() 31 { 32 return $this->usergroup; 33 } 34 35 /** 36 * @SuppressWarnings(PHPMD.StaticAccess) 37 * @inheritdoc 38 */ 39 public function getDomSubtree(\DOMDocument $document) 40 { 41 $valueElem = XMLHelper::createElementWithText($document, $this->itemName, $this->value); 42 43 return $valueElem; 44 } 45 46 /** 47 * @inheritdoc 48 */ 49 public function getCsvFragment() 50 { 51 return $this->value; 52 } 53} 54