Aerendir/bundle-features

View on GitHub
src/Manager/FeaturesManager.php

Summary

Maintainability
F
3 days
Test Coverage

Function findDifferences has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    private function findDifferences(SubscribedFeaturesCollection $newFeatures)
    {
        // Get the features from the cloned subscription
        $oldFeatures = $this->oldSubscription->getFeatures();

Severity: Minor
Found in src/Manager/FeaturesManager.php - About 5 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

File FeaturesManager.php has 396 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

/*
Severity: Minor
Found in src/Manager/FeaturesManager.php - About 5 hrs to fix

    Method findDifferences has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function findDifferences(SubscribedFeaturesCollection $newFeatures)
        {
            // Get the features from the cloned subscription
            $oldFeatures = $this->oldSubscription->getFeatures();
    
    
    Severity: Major
    Found in src/Manager/FeaturesManager.php - About 2 hrs to fix

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

          public function calculateTotalChargesForNewFeatures(SubscribedFeaturesCollection $newFeatures): MoneyInterface
          {
              $totalCharges = new Money([MoneyInterface::BASE_AMOUNT => 0, MoneyInterface::CURRENCY => $this->getSubscription()->getCurrency()]);
      
              // Calculate the added and removed Boolean features and the changed packages in Countable features
      Severity: Minor
      Found in src/Manager/FeaturesManager.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

      Method refreshCountableFeatures has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function refreshCountableFeatures(): void
          {
              $refreshInterval = SubscriptionInterface::MONTHLY;
              /** @var SubscribedCountableFeature $feature */
              foreach ($this->getSubscription()->getFeatures()->getValues() as $feature) {
      Severity: Minor
      Found in src/Manager/FeaturesManager.php - About 1 hr to fix

        Function refreshCountableFeatures has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            private function refreshCountableFeatures(): void
            {
                $refreshInterval = SubscriptionInterface::MONTHLY;
                /** @var SubscribedCountableFeature $feature */
                foreach ($this->getSubscription()->getFeatures()->getValues() as $feature) {
        Severity: Minor
        Found in src/Manager/FeaturesManager.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 calculateTotalChargesForNewFeatures has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function calculateTotalChargesForNewFeatures(SubscribedFeaturesCollection $newFeatures): MoneyInterface
            {
                $totalCharges = new Money([MoneyInterface::BASE_AMOUNT => 0, MoneyInterface::CURRENCY => $this->getSubscription()->getCurrency()]);
        
                // Calculate the added and removed Boolean features and the changed packages in Countable features
        Severity: Minor
        Found in src/Manager/FeaturesManager.php - About 1 hr to fix

          Method buildDefaultSubscriptionFeatures has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function buildDefaultSubscriptionFeatures(string $subscriptionInterval): SubscribedFeaturesCollection
              {
                  $activeUntil = Subscription::calculateActiveUntil($subscriptionInterval);
                  $features    = [];
          
          
          Severity: Minor
          Found in src/Manager/FeaturesManager.php - About 1 hr to fix

            Function calculateSubscriptionAmount has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                private function calculateSubscriptionAmount(): MoneyInterface
                {
                    $total = new Money([MoneyInterface::BASE_AMOUNT => 0, MoneyInterface::CURRENCY => $this->getSubscription()->getCurrency()]);
            
                    /** @var FeatureInterface $feature */
            Severity: Minor
            Found in src/Manager/FeaturesManager.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 refreshSubscription has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function refreshSubscription(): void
                {
                    $subscription = $this->getSubscription();
            
                    /** @var FeatureInterface $feature */
            Severity: Minor
            Found in src/Manager/FeaturesManager.php - About 55 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

            Function updateSubscription has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function updateSubscription(SubscribedFeaturesCollection $newFeatures = null): void
                {
                    if (null !== $newFeatures) {
                        /**
                         * Before all, update the features, setting the new enabled status or adding the feature if not already present.
            Severity: Minor
            Found in src/Manager/FeaturesManager.php - About 55 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

            Function updateUntilDates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                private function updateUntilDates(): void
                {
                    $validUntil = $this->getSubscription()->getNextRenewOn();
            
                    /** @var array $feature */
            Severity: Minor
            Found in src/Manager/FeaturesManager.php - About 35 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

            There are no issues that match your filters.

            Category
            Status