<?php
class GaugesFactory
{
    const SYSTEM_LOAD = 0;
    const CPU_TEMPERATURE = 1;
    const RAM_MEMORY_USAGE = 2;
    const HDD_MEMORY_USAGE = 3;
    
    public static function getGaugeInstance($name, $type, SystemOverview $model, $durationOrMountpoint = null)
    {
        switch ($type) {
            case self::CPU_TEMPERATURE:
                return self::getCPUTemperaturGauge($name, $model);
            case self::SYSTEM_LOAD:
                return self::getSystemLoadGauge($name, $model, $durationOrMountpoint);
            case self::RAM_MEMORY_USAGE:
                return self::getRamMemoryUsageGauge($name, $model);
            case self::HDD_MEMORY_USAGE:
                return self::getHddMemoryUsageGauge($name, $model, $durationOrMountpoint);
            default:
                break;
        }
    }

    private static function getSystemLoadGauge($name, $model, $duration = SystemLoadInfo::ONE_MINUTE)
    {
        if ($duration === SystemLoadInfo::ONE_MINUTE) {
            return new SystemLoadGauge($name, $model);
        } else if ($duration === SystemLoadInfo::FIVE_MINUTES) {
            return new SystemLoadGauge($name, $model);
        } else if ($duration === SystemLoadInfo::TEN_MINUTES) {
            return new SystemLoadGauge($name, $model);
        }
    }
    
    private static function getCPUTemperaturGauge($name, $model) {
        return new CPUTemperaturGauge($name, $model);
    }
    
    private static function getRamMemoryUsageGauge($name, $model) {
        return new RamMemoryUsageGauge($name, $model);
    }
    
    private static function getHddMemoryUsageGauge($name, $model, $mountpoint) 
    {
        return new HddMemoryUsageGauge($name, $model, $mountpoint);
    }
}
