<?php

namespace App\GenDocument\Vars;


/**
 * The class is used to return the name of the class which manages the requested pivot fields values.
 * @author Gabriel Grosu
 */
class PivotBuilderValues
{
	/**
	 * Returns the name of the class which is used for the current pivot fields values.
	 * @param String $pivot
	 */
	static public function fromPivot($pivot, $idPivot, $documentType=null) {
		$class = '\App\GenDocument\Vars\Values_'.ucfirst($pivot);
		$obj = $class::getInstance($idPivot);
		if ($documentType) {
			$obj->setDocumentType($documentType);
		}
		return $obj;
	}
}
