bavix/laravel-wallet

View on GitHub

Showing 23 of 26 total issues

File WalletServiceProvider.php has 413 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 5 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 106..117

    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 138..149

    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 withdrawFloat(float|int|string $amount, ?array $meta = null, bool $confirmed = true): Transaction
        {
            $math = app(MathServiceInterface::class);
            $decimalPlacesValue = app(CastServiceInterface::class)->getWallet($this)->decimal_places;
            $decimalPlaces = $math->powTen($decimalPlacesValue);
    Severity: Major
    Found in src/Traits/HasWalletFloat.php and 2 other locations - About 2 hrs to fix
    src/Traits/HasWalletFloat.php on lines 41..52
    src/Traits/HasWalletFloat.php on lines 60..68

    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 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 60..68
    src/Traits/HasWalletFloat.php on lines 78..86

    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
        {
            $math = app(MathServiceInterface::class);
            $decimalPlacesValue = app(CastServiceInterface::class)->getWallet($this)->decimal_places;
            $decimalPlaces = $math->powTen($decimalPlacesValue);
    Severity: Major
    Found in src/Traits/HasWalletFloat.php and 2 other locations - About 2 hrs to fix
    src/Traits/HasWalletFloat.php on lines 41..52
    src/Traits/HasWalletFloat.php on lines 78..86

    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 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 forceExchange has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Confirmed

          public function forceExchange(Wallet $to, int|string $amount, ExtraDtoInterface|array|null $meta = null): Transfer
          {
              return app(AtomicServiceInterface::class)->block($this, function () use ($to, $amount, $meta): Transfer {
                  $extraAssembler = app(ExtraDtoAssemblerInterface::class);
                  $prepareService = app(PrepareServiceInterface::class);
      Severity: Minor
      Found in src/Traits/CanExchange.php - About 1 hr to fix

        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
            {
                return app(AtomicServiceInterface::class)->block($this, function () use ($to, $amount, $meta): Transfer {
                    app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);
        
        
        Severity: Major
        Found in src/Traits/CanExchange.php and 1 other location - About 1 hr to fix
        src/Traits/HasWallet.php on lines 126..134

        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 transfer(Wallet $wallet, int|string $amount, ExtraDtoInterface|array|null $meta = null): Transfer
            {
                return app(AtomicServiceInterface::class)->block($this, function () use ($wallet, $amount, $meta): Transfer {
                    /** @var Wallet $this */
                    app(ConsistencyServiceInterface::class)->checkPotential($this, $amount);
        Severity: Major
        Found in src/Traits/HasWallet.php and 1 other location - About 1 hr to fix
        src/Traits/CanExchange.php on lines 40..47

        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 payFreeCart has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function payFreeCart(CartInterface $cart): array
              {
                  return app(AtomicServiceInterface::class)->block($this, function () use ($cart) {
                      $basketDto = $cart->getBasketDto();
                      $basketService = app(BasketServiceInterface::class);
          Severity: Minor
          Found in src/Traits/CartPay.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 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 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 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 transferLazy has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Confirmed

                                Wallet $from,
                                Wallet $to,
                                string $status,
                                float|int|string $amount,
                                ExtraDtoInterface|array|null $meta = null
                        Severity: Minor
                        Found in src/Services/PrepareServiceInterface.php - About 35 mins to fix

                          Method deposit 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
                            Severity
                            Category
                            Status
                            Source
                            Language