<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\Web\Classes\Ampel\Renderer;

class Ampel6Renderer extends AmpelRendererTextOrGrafisch
{
  protected function getAmpelGrafisch(int $status, \ToolSettings $settings): string
  {
    
    if (!(($status >= 0 && $status <= 4) || $status == 6)) {
      return '';
    }

    $optionstatustext = 'optionstatustext' . ($status + 1);
    $layoutDir = \Kufer\Web\Classes\KwResourceLocator::getInstance()->locateLayoutDirRelative();

    return \HTMLOperations::CreateImageTag(
      $layoutDir . $this->getImageName($status),
      $settings->{$optionstatustext},
      '',
      'ampel',
      'title="' . $settings->{$optionstatustext} . '"'
    );
  }

  private function getImageName(int $status): string
  {
    switch ($status) {
      case 0:
        return 'gelb.gif';
      case 1:
        return 'gruen.gif';
      case 2:
        return 'orange.gif';
      case 3:
        return 'rot.gif';
      case 4:
        return 'abgelaufen.gif';
      case 6:
        return 'keineanmeldung.gif';
    }

    return '';
  }
}