diff --git a/Business/Finance/Depreciation.php b/Business/Finance/Depreciation.php index cc0fd25b3..b6f89b96e 100644 --- a/Business/Finance/Depreciation.php +++ b/Business/Finance/Depreciation.php @@ -17,5 +17,51 @@ namespace phpOMS\Business\Finance; class Depreciation { + public static function getLinearDepreciationRate(float $start, int $duration) : float + { + return $start / $duration; + } + public static function getLinearDepreciationResidualInT(float $start, int $duration, int $t) : float + { + return $start - self::getLinearDepreciationRate($start, $duration) * $t; + } + + public static function getArithmeticProgressivDepreciationRate(float $start, int $duration) : float + { + return $start / ($duration * ($duration+1) / 2); + } + + public static function getArithmeticProgressivDepreciationInT(float $start, int $duration, int $t) : float + { + return $t * self::getArithmeticProgressivDepreciationRate($start, $duration); + } + + public static function getArithmeticProgressivDepreciationResidualInT(float $start, int $duration, int $t) : float + { + return $start - self::getArithmeticProgressivDepreciationRate($start, $duration) * $t * ($t + 1) / 2; + } + + public static function getGeometicProgressivDepreciationRate(float $start, float $residual, int $duration) : float + { + return (1-pow($residual / $start, 1 / $duration)); + } + + public static function getGeometicDegressivDepreciationInT(float $start, float $residual, int $duration, int $t) : float + { + return $start * (1 - self::getGeometicDegressivDepreciationRate($start, $residual, $duration)) ** $t; + } + + public static function getGeometicDegressivDepreciationResidualInT(float $start, float $residual, int $duration, int $t) : float + { + } + + public static function getGeometicProgressivDepreciationInT(float $start, float $residual, int $duration, int $t) : float + { + return $start * (1 - self::getGeometicProgressivDepreciationRate($start, $residual, $duration)) ** ($duration - $t + 1); + } + + public static function getGeometicProgressivDepreciationResidualInT(float $start, float $residual, int $duration, int $t) : float + { + } } \ No newline at end of file diff --git a/Business/Programming/Metrics.php b/Business/Programming/Metrics.php index fd461d7b4..3801affb2 100644 --- a/Business/Programming/Metrics.php +++ b/Business/Programming/Metrics.php @@ -40,4 +40,22 @@ class Metrics { { return (int) sqrt($a*$a+$b*$b+$c*$c); } + + /** + * Calculate the C.R.A.P score + * + * @latex r = \sqrt{a^{2} + b^{2} + c^{2}} + * + * @param int $a Assignments + * @param int $b Branches + * @param int $c Conditionals + * + * @return int + * + * @since 1.0.0 + */ + public static function CRAP(int $complexity, float $coverage) : int + { + return (int) ($complexity ** 2 * (1 - $coverage) ** 3 + $complexity); + } } \ No newline at end of file diff --git a/DataStorage/Database/Exception/InvalidConnectionConfigException.php b/DataStorage/Database/Exception/InvalidConnectionConfigException.php index c56ddff3e..5b1a3cef7 100644 --- a/DataStorage/Database/Exception/InvalidConnectionConfigException.php +++ b/DataStorage/Database/Exception/InvalidConnectionConfigException.php @@ -24,7 +24,7 @@ namespace phpOMS\DataStorage\Database\Exception; * @link http://orange-management.com * @since 1.0.0 */ -class InvalidConnectionConfigException extends \RuntimeException +class InvalidConnectionConfigException extends \InvalidArgumentException { /** * Constructor.