<commit_before><?php
namespace Jazzee\Display;

/**
 * Union display takes other displays which may limit applicant data and
 * returns the maximum union of these displays
 *
 * @author  <NAME>  <<EMAIL>>
 * @license http://jazzee.org/license BSD-3-Clause
 */
class Union implements \Jazzee\Interfaces\Display
{ 
  protected $_pageIds;
  protected $_elementIds;
  protected $_elements;
  protected $_displays;

  /**
   * Setup arrays
   */
  public function __construct()
  {
    $this->_displays = array();
    $this->calculateUntion();
  }
  
  /**
   * Add a display to our set
   * @param \Jazzee\Interfaces\Display $display
   */
  public function addDisplay(\Jazzee\Interfaces\Display $display){
    $this->_displays[$display->getId()] = $display;
    $this->calculateUntion();
  }
  
  
  /**
   * Calculate display union
   */
  protected function calculateUntion() {
    $this->_pageIds = array();
    $this->_elementIds = array();
    
    $elements = array();
    foreach($this->_displays as $display){
      $this->_pageIds = array_unique(array_merge($this->_pageIds, $display->getPageIds()));
      $this->_elementIds = array_unique(array_merge($this->_elementIds, $display->getElementIds()));
      foreach($display->listElements() as $element){
        $elements[$element->type.$element->name] = $element;
      }
    }
    $this->_elements = array_values($elements);
  }

  /**
   * Get the name of the display
   * 
   * @return string
   */
  public function getName(){
    return 'Union Display';
  }

  /**
   * Get id
   * <commit_msg>In Union displays use the pageId otherwise page elements dont display if there are more than one with the same name on an application.<commit_after><?php
namespace Jazzee\Display;

/**
 * Union display takes other displays which may limit applicant data and
 * returns the maximum union of these displays
 *
 * @author  <NAME>  <<EMAIL>>
 * @license http://jazzee.org/license BSD-3-Clause
 */
class Union implements \Jazzee\Interfaces\Display
{ 
  protected $_pageIds;
  protected $_elementIds;
  protected $_elements;
  protected $_displays;

  /**
   * Setup arrays
   */
  public function __construct()
  {
    $this->_displays = array();
    $this->calculateUntion();
  }
  
  /**
   * Add a display to our set
   * @param \Jazzee\Interfaces\Display $display
   */
  public function addDisplay(\Jazzee\Interfaces\Display $display){
    $this->_displays[$display->getId()] = $display;
    $this->calculateUntion();
  }
  
  
  /**
   * Calculate display union
   */
  protected function calculateUntion() {
    $this->_pageIds = array();
    $this->_elementIds = array();
    
    $elements = array();
    foreach($this->_displays as $display){
      $this->_pageIds = array_unique(array_merge($this->_pageIds, $display->getPageIds()));
      $this->_elementIds = array_unique(array_merge($this->_elementIds, $display->getElementIds()));
      foreach($display->listElements() as $element){
        $elements[$element->type.$element->name.$element->pageId] = $element;
      }
    }
    $this->_elements = array_values($elements);
  }

  /**
   * Get the name of the display
   * 
   * @return string
   */
  public function getName(){
    return 'Union Display';
  }

  /**
   * Get id
   * 
{'fraction_non_alphanumeric': 0.1436039360393604, 'fraction_numerical': 0.0006150061500615006, 'mean_word_length': 3.1866151866151866, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5690649', 'n_tokens_mistral': 1005, 'n_tokens_neox': 972, 'n_words': 237}