Aerendir/stripe-bundle

View on GitHub

Showing 52 of 52 total issues

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

    public function notifyAction(
        Request $request,
        EntityManagerInterface $entityManager,
        EventDispatcherInterface $eventDispatcher,
        StripeManager $stripeManager,
Severity: Minor
Found in src/Controller/WebhookController.php - About 1 hr to fix

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

        public function toStripe(string $action): array
        {
            if (self::ACTION_CREATE !== $action && 'update' !== $action) {
                throw new \InvalidArgumentException('StripeLocalCustomer::__toArray() accepts only "create" or "update" as parameter.');
            }
    Severity: Minor
    Found in src/Model/StripeLocalCustomer.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 callStripeApi has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function callStripeApi(string $endpoint, string $action, array $arguments)
        {
            $return = null;
    
            try {
    Severity: Minor
    Found in src/Manager/StripeManager.php - About 1 hr to fix

      Method toStripe has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function toStripe(string $action): array
          {
              $return = [];
      
              // Prepare the array for creation
      Severity: Minor
      Found in src/Model/StripeLocalCharge.php - About 1 hr to fix

        Method checkApiVersion has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function checkApiVersion(SymfonyStyle $ioWriter): void
            {
                if (false === \class_exists(Crawler::class)) {
                    $ioWriter->error('The Symfony DomCrawler component is not installed and it is required to run this command.
        Run "composer req symfony/domcrawler" to install it.');
        Severity: Minor
        Found in dev/Command/CheckCommand.php - About 1 hr to fix

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

              public function getConfigTreeBuilder(): TreeBuilder
              {
                  $treeBuilder = new TreeBuilder('shq_stripe');
                  $rootNode    = $treeBuilder->getRootNode();
          
          
          Severity: Minor
          Found in src/DependencyInjection/Configuration.php - About 1 hr to fix

            Method notifyAction has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    Request $request,
                    EntityManagerInterface $entityManager,
                    EventDispatcherInterface $eventDispatcher,
                    StripeManager $stripeManager,
                    EventGuesser $eventGuesser,
            Severity: Major
            Found in src/Controller/WebhookController.php - About 1 hr to fix

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

                  public function callStripeApi(string $endpoint, string $action, array $arguments)
                  {
                      $return = null;
              
                      try {
              Severity: Minor
              Found in src/Manager/StripeManager.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 handleException has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function handleException(ExceptionInterface $e): bool
                  {
                      switch (\get_class($e)) {
                          case RateLimitException::class:
                              // We have to retry with an exponential backoff if is not reached the maximum number of retries
              Severity: Minor
              Found in src/Manager/StripeManager.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 compareLocalPropertiesWithSdkOnes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function compareLocalPropertiesWithSdkOnes(string $localModelClass, string $sdkModelClass, array $propertiesToCompare): array
                  {
                      $failures = [];
                      foreach ($propertiesToCompare as $propertyToCompare) {
                          $localPropertyDocBlock = ReflectionHelper::getLocalModelPropertyDocComment($localModelClass, $propertyToCompare);
              Severity: Minor
              Found in dev/Command/CheckCommand.php - About 1 hr to fix

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

                    public static function getModelClasses(): array
                    {
                        static $modelClasses = null;
                
                        if (\is_array($modelClasses)) {
                Severity: Minor
                Found in dev/Helper/ReflectionHelper.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 compareLocalPropertiesWithSdkOnes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function compareLocalPropertiesWithSdkOnes(string $localModelClass, string $sdkModelClass, array $propertiesToCompare): array
                    {
                        $failures = [];
                        foreach ($propertiesToCompare as $propertyToCompare) {
                            $localPropertyDocBlock = ReflectionHelper::getLocalModelPropertyDocComment($localModelClass, $propertyToCompare);
                Severity: Minor
                Found in dev/Command/CheckCommand.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

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

                    public function __construct(string $secretKey, string $debug, string $statementDescriptor, ChargeSyncer $chargeSyncer, CustomerSyncer $customerSyncer, WebhookEventSyncer $webhookEventSyncer, LoggerInterface $logger = null)
                Severity: Major
                Found in src/Manager/StripeManager.php - About 50 mins to fix

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

                      public static function getSdkModelPropertiesDocComments(string $sdkModelClass): array
                      {
                          if (false === isset(self::$sdkModelsCache[$sdkModelClass])) {
                              $reflectedSdkModel = new \ReflectionClass($sdkModelClass);
                              $docComment        = self::getDockBlockFactory()->create($reflectedSdkModel->getDocComment());
                  Severity: Minor
                  Found in dev/Helper/ReflectionHelper.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

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

                      public function syncLocalSources(StripeLocalResourceInterface $localResource, ApiResource $stripeResource): void
                      {
                          /** @var StripeLocalCustomer $localResource */
                          if ( ! $localResource instanceof StripeLocalCustomer) {
                              throw new \InvalidArgumentException('CustomerSyncer::syncLocalFromStripe() accepts only StripeLocalCustomer objects as first parameter.');
                  Severity: Minor
                  Found in src/Syncer/CustomerSyncer.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

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

                      public function callStripeObject(ApiResource $object, string $method, array $arguments = [])
                      {
                          try {
                              switch (\count($arguments)) {
                                  // Method has no signature (it doesn't accept any argument)
                  Severity: Minor
                  Found in src/Manager/StripeManager.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

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

                      public function syncStripeFromLocal(ApiResource $stripeResource, StripeLocalResourceInterface $localResource): void
                      {
                          /** @var Customer $stripeResource */
                          if ( ! $stripeResource instanceof Customer) {
                              throw new \InvalidArgumentException('CustomerSyncer::syncStripeFromLocal() accepts only Stripe\Customer objects as first parameter.');
                  Severity: Minor
                  Found in src/Syncer/CustomerSyncer.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

                  Avoid too many return statements within this method.
                  Open

                                  return [
                                      self::TYPE   => \constant(StripeWebhookReviewEvent::class . '::' . $pieces[self::TYPE]),
                                      self::OBJECT => $dispatchingEvent,
                                  ];
                  Severity: Major
                  Found in src/Util/EventGuesser.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return [
                                        self::TYPE   => \constant(StripeWebhookTransferEventEvent::class . '::' . $pieces[self::TYPE]),
                                        self::OBJECT => $dispatchingEvent,
                                    ];
                    Severity: Major
                    Found in src/Util/EventGuesser.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return [
                                          self::TYPE   => \constant(StripeWebhookSkuEventEvent::class . '::' . $pieces[self::TYPE]),
                                          self::OBJECT => $dispatchingEvent,
                                      ];
                      Severity: Major
                      Found in src/Util/EventGuesser.php - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language