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();
- Read upRead up
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);
/*
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();
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
- Read upRead up
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) {
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) {
- Read upRead up
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
Method buildDefaultSubscriptionFeatures
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildDefaultSubscriptionFeatures(string $subscriptionInterval): SubscribedFeaturesCollection
{
$activeUntil = Subscription::calculateActiveUntil($subscriptionInterval);
$features = [];
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 */
- Read upRead up
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 */
- Read upRead up
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.
- Read upRead up
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 */
- Read upRead up
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"