Showing 42 of 56 total issues
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);
/*
File Configuration.php
has 375 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
/*
Method getConfigTreeBuilder
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('shq_features');
$rootNode = $treeBuilder->getRootNode();
Subscription
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class Subscription implements SubscriptionInterface
{
/** @ORM\Column(name="currency", type="currency", nullable=true) */
private ?Currency $currency = null;
Function isFree
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function isFree(): bool
{
if (empty($this->netPrices) && empty($this->grossPrices)) {
return true;
}
- 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
Configuration
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
final class Configuration implements ConfigurationInterface
{
/** @var string[] The allowed drawers */
private const ALLOWED_DRAWERS = ['plain_text'];
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();
Invoice
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class Invoice implements InvoiceInterface
{
private const SECTION_DEFAULT = '_default';
/** @ORM\Column(name="currency", type="currency") */
Function setPrices
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function setPrices(array $settingPrices, string $pricesType)
{
$this->pricesType = $pricesType;
$priceProperty = FeatureInterface::PRICE_NET === $this->pricesType ? 'netPrices' : 'grossPrices';
$setPrices = $this->$priceProperty;
- 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 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 buildInvoiceTextTable
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function buildInvoiceTextTable(InvoiceSection $section): string
{
$tableData = [
[
'quantity' => \mb_strtoupper($this->getTranslator()->trans('shq_features.invoice.quantity.label', [], 'Invoice')),
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 __construct
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(string $kind, ?array $elements = [])
{
if (false === \in_array($kind, [ConfiguredFeaturesCollection::KIND, SubscribedFeaturesCollection::KIND])) {
throw new \InvalidArgumentException(sprintf('Features kind can be only "configured" or "subscribed". You passed "%s".', $kind));
}
- 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 validatePackages
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function validatePackages(string $set, string $feature, array $packs, string $subscriptionType): void
{
// If empty, may be because it doesn't exist and the TreeBuilder created it as an empty array, else...
if (false === empty($packs)) {
// ... It contains packages: validate the number of units and their prices
- 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 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
Function buildPopulatingFeatures
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function buildPopulatingFeatures(?array $addedFeatures): array
{
$populatingFeatures = [];
// If we $added features is not null, then we have to add only them to the Invoice section as the invoice is
- 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 populateSection
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function populateSection(InvoiceSection $section, array $addedFeatures = null): void
{
/** @var SubscribedBooleanFeature $feature */
foreach ($this->buildPopulatingFeatures($addedFeatures) as $feature) {
$grossPrice = null;
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 draw
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function draw(InvoiceInterface $invoice): array
{
$detailsTables = [];
foreach ($invoice->getSections() as $sectionId => $section) {
$detailsTables[$sectionId] = $this->buildInvoiceTextTable($section);