uruba/FinanCalc

View on GitHub

Showing 18 of 109 total issues

DebtAmortizator has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

    class DebtAmortizator extends CalculatorAbstract
    {
        /** @var  RepaymentInstance[] */
        // list of individual debt's repayments as an array of RepaymentInstance objects
        protected $debtRepayments;
Severity: Minor
Found in src/Calculators/DebtAmortizator.php - About 2 hrs to fix

    AnnuityCalculator has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

        class AnnuityCalculator extends CalculatorAbstract
        {
    
            // amount of each individual payment = 'K'
            protected $annuitySinglePaymentAmount;
    Severity: Minor
    Found in src/Calculators/AnnuityCalculator.php - About 2 hrs to fix

      Function populateFactoryClassesArray has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

              private function populateFactoryClassesArray()
              {
                  $factoryFiles = glob(FinanCalc::getPath() . Config::getConfigField('factories_relative_path') . '/*.php');
                  $factoriesNamespace = Config::getConfigField('factories_namespace');
      
      
      Severity: Minor
      Found in src/FinanCalc.php - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      TimeSpan has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

          class TimeSpan
          {
              /** @var  DateTime */
              private $startDate;
              /** @var  DateTime */
      Severity: Minor
      Found in src/Utils/Time/TimeSpan.php - About 2 hrs to fix

        Method getAnnuityValue has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public function getAnnuityValue(
                    AnnuityPaymentTypes $annuityPaymentType = null,
                    AnnuityValueTypes $annuityValueType
                ) {
                    // if the number of the annuity's compounding periods
        Severity: Major
        Found in src/Calculators/AnnuityCalculator.php - About 2 hrs to fix

          Method getBondFairValue has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public function getBondFairValue()
                  {
                      // we need to get the coupon rate per payment period = c/payment frequency
                      $couponRateForPeriod = MathFuncs::div(
                          $this->bondAnnualCouponRate,
          Severity: Minor
          Found in src/Calculators/BondFairValueCalculator.php - About 1 hr to fix

            Function getResultAsArray has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                    final public function getResultAsArray(array $propResultArray = null)
                    {
                        if ($propResultArray === null) {
                            if ($this->propResultArray !== null && is_array($this->propResultArray)) {
                                $propResultArray = $this->propResultArray;
            Severity: Minor
            Found in src/Interfaces/Calculator/CalculatorAbstract.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function getAnnuityValue has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function getAnnuityValue(
                        AnnuityPaymentTypes $annuityPaymentType = null,
                        AnnuityValueTypes $annuityValueType
                    ) {
                        // if the number of the annuity's compounding periods
            Severity: Minor
            Found in src/Calculators/AnnuityCalculator.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method populateFactoryClassesArray has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    private function populateFactoryClassesArray()
                    {
                        $factoryFiles = glob(FinanCalc::getPath() . Config::getConfigField('factories_relative_path') . '/*.php');
                        $factoriesNamespace = Config::getConfigField('factories_namespace');
            
            
            Severity: Minor
            Found in src/FinanCalc.php - About 1 hr to fix

              Method getApproxBondYTM has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      public function getApproxBondYTM()
                      {
                          // we need to calculate the coupon payment C = F*(c/payment frequency)
                          $couponPayment =
                              MathFuncs::mul(
              Severity: Minor
              Found in src/Calculators/BondYTMCalculator.php - About 1 hr to fix

                Method getResultAsArray has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        final public function getResultAsArray(array $propResultArray = null)
                        {
                            if ($propResultArray === null) {
                                if ($this->propResultArray !== null && is_array($this->propResultArray)) {
                                    $propResultArray = $this->propResultArray;
                Severity: Minor
                Found in src/Interfaces/Calculator/CalculatorAbstract.php - About 1 hr to fix

                  Method newCustomCouponFrequencyBond has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                              $bondFaceValue,
                              $bondAnnualCouponRate,
                              $bondVIR,
                              $bondYearsToMaturity,
                              $bondPaymentFrequency
                  Severity: Minor
                  Found in src/Calculators/Factories/BondFairValueCalculatorFactory.php - About 35 mins to fix

                    Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                                $bondFaceValue,
                                $bondAnnualCouponRate,
                                $bondVIR,
                                $bondYearsToMaturity,
                                $bondPaymentFrequency = 1
                    Severity: Minor
                    Found in src/Calculators/BondFairValueCalculator.php - About 35 mins to fix

                      Method newCustomCouponFrequencyBond has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                                  $bondFaceValue,
                                  $bondMarketValue,
                                  $bondAnnualCouponRate,
                                  $bondYearsToMaturity,
                                  $bondPaymentFrequency
                      Severity: Minor
                      Found in src/Calculators/Factories/BondYTMCalculatorFactory.php - About 35 mins to fix

                        Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                    $bondFaceValue,
                                    $bondAnnualCouponRate,
                                    $bondAnnualYield,
                                    $bondYearsToMaturity,
                                    $bondPaymentFrequency = 1
                        Severity: Minor
                        Found in src/Calculators/BondDurationCalculator.php - About 35 mins to fix

                          Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                      $bondFaceValue,
                                      $bondMarketValue,
                                      $bondAnnualCouponRate,
                                      $bondYearsToMaturity,
                                      $bondPaymentFrequency = 1
                          Severity: Minor
                          Found in src/Calculators/BondYTMCalculator.php - About 35 mins to fix

                            Method newCustomCouponFrequencyBond has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                        $bondFaceValue,
                                        $bondAnnualCouponRate,
                                        $bondAnnualYield,
                                        $bondYearsToMaturity,
                                        $bondPaymentFrequency
                            Severity: Minor
                            Found in src/Calculators/Factories/BondDurationCalculatorFactory.php - About 35 mins to fix

                              Function setProperty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                      final protected function setProperty($name, $value, $callbackBefore = null)
                                      {
                                          if (is_callable($callbackBefore)) {
                                              $callbackBefore($value);
                                          }
                              Severity: Minor
                              Found in src/Interfaces/Calculator/CalculatorAbstract.php - About 25 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Severity
                              Category
                              Status
                              Source
                              Language