<?php
namespace App\Bsp\Settlement;

/**
 * One specific result
 * Used as part of CompareWithImportedServiceResults
 * @author Lucian Sirbu
 */
class CompareWithImportedServiceResult
{
	/**
	 * Gathered details list
	 * @var array
	 */
	public $details = [];

	/**
	 * The result in the ImportedOrder section
	 * @var mixed
	 */
	public $importedService = null;

	/**
	 * The result in the BSP section
	 * @var mixed
	 */
	public $bspRow = null;

	/**
	 * Get the first internal data that actually has data
	 * @return mixed
	 */
	public function getAny()
	{
		return ($this->importedService?:$this->bspRow);
	}

	/**
	 * Check if any differences are present
	 * @return boolean
	 */
	public function hasDifferences()
	{
		return (bool)$this->details;

		// NOTE: I suppose this should work better, but some tests are failing, so I'll leave it like this for now
		// return (bool)array_filter($this->details, function($item) { 
		// 	return $item!='identical'; 
		// });

	}

	/**
	 * Check if a certain status is present
	 * @return boolean
	 */
	public function hasStatusRaw($status)
	{
		return (bool)in_array($status, $this->details);
	}

}
