<?php
namespace App\GenDocument\Vars;

/**
 * Mock class for the config classes
 * @author Lucian Sirbu
 */
class ConfigMock
{
	/**
	 * The mocked class
	 * @var \App\GenDocument\Vars\ConfigAbstract
	 */
	private $backend = null;
	public function __construct(\App\GenDocument\Vars\ConfigAbstract $backend)
	{
		$this->backend = $backend;
	}

	/**
	 * Return a dumy value
	 * @param String $field
	 * @return number|string|NULL
	 */
	public function getValue($field)
	{
		switch ($this->backend->getType($field)) {
			case 'numeric':
				return 1;
			break;
			case 'date':
				return '2000-01-02 03:04:05';
			break;
			case 'string':
			case 'text':
					return 'sample';
			break;
		}

		return null;
	}

	/**
	 * Check if the variable exists
	 * @param String $field
	 * @return boolean
	 */
	public function exists($field)
	{
		return $this->backend->exists($field);
	}
}

