mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
62 lines
1.3 KiB
PHP
62 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Orange Management
|
|
*
|
|
* PHP Version 7.1
|
|
*
|
|
* @package TBD
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link http://website.orange-management.de
|
|
*/
|
|
declare(strict_types = 1);
|
|
|
|
namespace phpOMS\Business\Programming;
|
|
|
|
/**
|
|
* Programming metrics
|
|
*
|
|
* This class provides basic programming metric calculations.
|
|
*
|
|
* @package Framework
|
|
* @license OMS License 1.0
|
|
* @link http://website.orange-management.de
|
|
* @since 1.0.0
|
|
*/
|
|
class Metrics {
|
|
/**
|
|
* Calculate ABC metric 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 abcScore(int $a, int $b, int $c) : int
|
|
{
|
|
return (int) sqrt($a * $a + $b * $b + $c * $c);
|
|
}
|
|
|
|
/**
|
|
* Calculate the C.R.A.P score
|
|
*
|
|
* @latex r = com^{2} \times (1 - cov)^{3} + com
|
|
*
|
|
* @param int $complexity Complexity
|
|
* @param float $coverage Coverage
|
|
*
|
|
* @return int
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function CRAP(int $complexity, float $coverage) : int
|
|
{
|
|
return (int) ($complexity ** 2 * (1 - $coverage) ** 3 + $complexity);
|
|
}
|
|
} |