<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */

namespace Kufer\Web\Classes\Anmeldung\OnlinePortal;

class StornoLink
{
  private $belid;
  private $stornohash;

  public const HL_NAME = 'AbmeldenStornoLink';

  public function __construct($belid, $stornohash)
  {
    $this->belid = $belid;
    $this->stornohash = $stornohash;
  }

  
  public function getStornoLink(?string $linkPattern = '')
  {
    if ($linkPattern == '') {
      $linkPattern = static::getLinkPatternFromDb();
    }
    
    return str_replace(array('<BELEGID>', '<STORNOHASH>'), array($this->belid, $this->stornohash), $linkPattern);
  }

  public static function getLinkPatternFromDb()
  {
    $hlgrundsys = \DBWorkHLGrundSys::getDefaultInstance();
    $anmartWeitermeldung = $hlgrundsys->getFeldWert(static::HL_NAME);

    return $anmartWeitermeldung;
  }
}