bavix/laravel-wallet

View on GitHub

Showing 24 of 27 total issues

File WalletServiceProvider.php has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Confirmed

<?php

declare(strict_types=1);

namespace Bavix\Wallet;
Severity: Minor
Found in src/WalletServiceProvider.php - About 6 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function forceTransferFloat(
            Wallet $wallet,
            float|int|string $amount,
            ExtraDtoInterface|array|null $meta = null
        ): Transfer {
    Severity: Major
    Found in src/Traits/HasWalletFloat.php and 1 other location - About 2 hrs to fix
    src/Traits/HasWalletFloat.php on lines 201..221

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 135.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function transferFloat(
            Wallet $wallet,
            float|int|string $amount,
            ExtraDtoInterface|array|null $meta = null
        ): Transfer {
    Severity: Major
    Found in src/Traits/HasWalletFloat.php and 1 other location - About 2 hrs to fix
    src/Traits/HasWalletFloat.php on lines 283..306

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 135.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        public function forceWithdrawFloat(
            float|int|string $amount,
            ?array $meta = null,
            bool $confirmed = true
        ): Transaction {
    Severity: Major
    Found in src/Traits/HasWalletFloat.php and 2 other locations - About 2 hrs to fix
    src/Traits/HasWalletFloat.php on lines 88..107
    src/Traits/HasWalletFloat.php on lines 128..147

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 132.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        public function withdrawFloat(float|int|string $amount, ?array $meta = null, bool $confirmed = true): Transaction
        {
            // Get the math service.
            $math = app(MathServiceInterface::class);
    
    
    Severity: Major
    Found in src/Traits/HasWalletFloat.php and 2 other locations - About 2 hrs to fix
    src/Traits/HasWalletFloat.php on lines 48..69
    src/Traits/HasWalletFloat.php on lines 88..107

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 132.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        public function depositFloat(float|int|string $amount, ?array $meta = null, bool $confirmed = true): Transaction
        {
            // Get the math service.
            $math = app(MathServiceInterface::class);
    
    
    Severity: Major
    Found in src/Traits/HasWalletFloat.php and 2 other locations - About 2 hrs to fix
    src/Traits/HasWalletFloat.php on lines 48..69
    src/Traits/HasWalletFloat.php on lines 128..147

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 132.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method forceExchange has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Confirmed

        public function forceExchange(Wallet $to, int|string $amount, ExtraDtoInterface|array|null $meta = null): Transfer
        {
            // Get the atomic service to execute the exchange operation as a single, indivisible action.
            $atomicService = app(AtomicServiceInterface::class);
    
    
    Severity: Major
    Found in src/Traits/CanExchange.php - About 2 hrs to fix

      File CartPay.php has 255 lines of code (exceeds 250 allowed). Consider refactoring.
      Confirmed

      <?php
      
      declare(strict_types=1);
      
      namespace Bavix\Wallet\Traits;
      Severity: Minor
      Found in src/Traits/CartPay.php - About 2 hrs to fix

        Method services has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Confirmed

            private function services(array $configure, array $cache): void
            {
                $this->app->singleton(AssistantServiceInterface::class, $configure['assistant'] ?? AssistantService::class);
                $this->app->singleton(AtmServiceInterface::class, $configure['atm'] ?? AtmService::class);
                $this->app->singleton(AtomicServiceInterface::class, $configure['atomic'] ?? AtomicService::class);
        Severity: Major
        Found in src/WalletServiceProvider.php - About 2 hrs to fix

          Method payFreeCart has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function payFreeCart(CartInterface $cart): array
              {
                  $atomicService = app(AtomicServiceInterface::class);
                  $eagerLoaderService = app(EagerLoaderServiceInterface::class);
                  $basketService = app(BasketServiceInterface::class);
          Severity: Minor
          Found in src/Traits/CartPay.php - About 2 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Confirmed

                public function transfer(Wallet $wallet, int|string $amount, ExtraDtoInterface|array|null $meta = null): Transfer
                {
                    // Wrap the transfer in an atomic block to ensure consistency and prevent race conditions.
                    return app(AtomicServiceInterface::class)->block($this, function () use ($wallet, $amount, $meta): Transfer {
                        /** @var Wallet $this */
            Severity: Major
            Found in src/Traits/HasWallet.php and 1 other location - About 1 hr to fix
            src/Traits/CanExchange.php on lines 51..67

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 114.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Confirmed

                public function exchange(Wallet $to, int|string $amount, ExtraDtoInterface|array|null $meta = null): Transfer
                {
                    // Execute the exchange operation atomically
                    // AtomicServiceInterface ensures that the exchange operation is performed as a single, indivisible action
                    // to prevent race conditions and ensure consistency.
            Severity: Major
            Found in src/Traits/CanExchange.php and 1 other location - About 1 hr to fix
            src/Traits/HasWallet.php on lines 254..265

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 114.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method assemblers has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Confirmed

                private function assemblers(array $configure): void
                {
                    $this->app->singleton(
                        AvailabilityDtoAssemblerInterface::class,
                        $configure['availability'] ?? AvailabilityDtoAssembler::class
            Severity: Minor
            Found in src/WalletServiceProvider.php - About 1 hr to fix

              Method create has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Confirmed

                      int $depositId,
                      int $withdrawId,
                      string $status,
                      Model $fromModel,
                      Model $toModel,
              Severity: Major
              Found in src/Internal/Assembler/TransferDtoAssemblerInterface.php - About 1 hr to fix

                Method create has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Confirmed

                        Wallet $fromWallet,
                        Wallet $toWallet,
                        int $discount,
                        string $fee,
                        TransactionDtoInterface $withdrawDto,
                Severity: Major
                Found in src/Internal/Assembler/TransferLazyDtoAssembler.php - About 1 hr to fix

                  Method create has 9 arguments (exceeds 4 allowed). Consider refactoring.
                  Confirmed

                          Wallet $fromWallet,
                          Wallet $toWallet,
                          int $discount,
                          string $fee,
                          TransactionDtoInterface $withdrawDto,
                  Severity: Major
                  Found in src/Internal/Assembler/TransferLazyDtoAssemblerInterface.php - About 1 hr to fix

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

                            Wallet $from,
                            WalletModel $fromWallet,
                            Wallet $to,
                            WalletModel $toWallet,
                            string $status,
                    Severity: Major
                    Found in src/Services/PrepareServiceInterface.php - About 50 mins to fix

                      Method create has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Confirmed

                              Model $payable,
                              int $walletId,
                              string $type,
                              float|int|string $amount,
                              bool $confirmed,
                      Severity: Major
                      Found in src/Internal/Assembler/TransactionDtoAssemblerInterface.php - About 50 mins to fix

                        Method withdraw has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Confirmed

                                Wallet $wallet,
                                float|int|string $amount,
                                ?array $meta,
                                bool $confirmed = true,
                                ?string $uuid = null
                        Severity: Minor
                        Found in src/Services/PrepareServiceInterface.php - About 35 mins to fix

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

                                  Wallet $wallet,
                                  string $type,
                                  float|int|string $amount,
                                  ?array $meta,
                                  bool $confirmed = true
                          Severity: Minor
                          Found in src/Services/TransactionServiceInterface.php - About 35 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language