<?php

namespace ThurData\Servers\KerioEmail\Core\FileReader\Reader;

use ThurData\Servers\KerioEmail\Core\ServiceLocator;

/**
 * Description of Json
 *
 * @autor ThurData <info@thurdata.ch>
 */
class Js extends AbstractType
{

    protected function loadFile()
    {
        $return = '';
        try
        {
            if (file_exists($this->path . DS . $this->file))
            {
                $return = file_get_contents($this->path . DS . $this->file);
                foreach ($this->renderData as $key => $value)
                {
                    $return = str_replace("#$key#", $value, $return);
                }
            }
        }
        catch (\Exception $e)
        {
            ServiceLocator::call('errorManager')->addError(self::class, $e->getMessage(), $e->getTrace());
        }

        $this->data = $return;
    }
}
