Source of file SDLTRiskCalc.php
Size: 0,974 Bytes - Last Modified: 2021-12-23T10:08:54+00:00
/var/www/docs.ssmods.com/process/src/src/Trait/SDLTRiskCalc.php
123456789101112131415161718192021222324252627282930313233343536373839404142 | <?php /** * This file contains the "SDLTRiskCalc" trait. * * @category SilverStripe_Project * @package SDLT * @author Catalyst I.T. SilverStripe Team 2019 <silverstripedev@catalyst.net.nz> * @copyright NZ Transport Agency * @license BSD-3 * @link https://www.catalyst.net.nz */ namespace NZTA\SDLT\Traits; use NZTA\SDLT\Formulae\RiskFormula; trait SDLTRiskCalc { /** * Returns an instance of the appropriate {@link RiskFormula}. * * @return RiskFormula * @throws \Exception */ public function riskFactory() : RiskFormula { if (!$this->isRiskType()) { throw new \Exception('Record is not a "Risk" type.'); } $selectedFormula = sprintf('NZTA\SDLT\Formulae\%s', $this->RiskCalculation); if (!class_exists($selectedFormula)) { throw new \Exception(sprintf('Could not find formula: %s', $selectedFormula)); } return $selectedFormula::create(); } } |