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

namespace Kufer\Web\Classes\Ampel\Renderer;

abstract class Ampel4Renderer extends AmpelRendererTextOrGrafisch
{
  abstract protected function getImageDir(): string;

  protected function getAmpelGrafisch(int $status, \ToolSettings $settings): string
  {
    if ($status < 0 || $status > 3) {
      return '';
    }

    $optionstatustext = 'optionstatustext' . ($status + 1);

    return \HTMLOperations::CreateImageTag(
      $this->getImageDir() . $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';
    }

    return '';
  }
}