<?php

namespace App\Reports\Sources\UsersVisits;

class PopulateLoopRecords extends \App\Reports\Sources\PopulateLoopRecordsAbstract
{

	/**
	 * These are the standard columns that we expect are filled in during the loop records. The list
	 * may not contain anyting
	 * @var array
	 */
	protected array $processStandardColumns = [ 'extraDataList' ];

	/**
	 * {@inheritDoc}
	 * @see \App\Reports\Sources\PopulateLoopRecordsAbstract::updateReportStdColumns()
	 */
	protected function updateReportStdColumns(array $currentRow) :array
	{


		// loads all the standard columns from
		$tableColumns = $this->columnsManager->getStdColumns();

		$updateColumns = [];

		// extraData
		if ($tableColumns['extraDataList'] and $currentRow['extraDataList']){
			$thisExtraData = unserialize($currentRow['extraDataList']);
			if (is_array($thisExtraData)) {
				$thisExtraDataStr = '';
				foreach($thisExtraData as $var=>$value){
					$thisExtraDataStr .= htmlClean($var).": ".htmlClean($value)."&#10;";
				}
				if ($thisExtraDataStr) {
					$updateColumns['extraDataList'] = $thisExtraDataStr;
				}
			}
		}

		return $updateColumns;

	}

}