<?php
namespace App\GdsSalesReport\Parser\FileFormats;

class FileFormats
{
	/**
	 * The internal list of systems
	 * @var array:\App\GdsSalesReport\Parser\FileFormats\FileFormat
	 */
    protected $formats = [];

	/**
	 * Append a system to the list
	 * @param \Modules\Admin\FluxInstances\Types\System $system
	 */
	public function append(\App\GdsSalesReport\Parser\FileFormats\FileFormat $format)
	{
		$this->formats[] = $format;
    }

	/**
	 * Get the list with all the gathered systems
	 * @return array:\Modules\Admin\FluxInstances\Types\System
	 */
	public function getAll()
	{
        $formats = $this->formats;

        usort($formats, function ($a, $b) {
            $ret = 0;
            if (!$ret) {
                return $ret = $a->priority - $b->priority;
            }

            if (!$ret) {
                return $ret = strcasecmp($b->label, $a->label);
            }

            return $ret;
        });
		return $formats;
	}
}
