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

class FileFormats
{
	/**
	 * The internal list of systems
	 * @var array:\Modules\Admin\FluxInstances\Types\System
	 */
    protected $formats = [];

	/**
	 * Append a system to the list
	 * @param \Modules\Admin\FluxInstances\Types\System $system
	 */
	public function append(\App\Bsp\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;
	}
}
