File tree Expand file tree Collapse file tree 6 files changed +26
-23
lines changed Expand file tree Collapse file tree 6 files changed +26
-23
lines changed Original file line number Diff line number Diff line change 4343    "phpunit/phpunit" : " ^9.5" 
4444    "rector/rector" : " ^0.14" 
4545    "symplify/easy-coding-standard" : " ^11.1" 
46-     "vimeo/psalm" : " ^4.26 " 
46+     "vimeo/psalm" : " ^4.27 " 
4747  },
4848  "suggest" : {
4949    "bavix/laravel-wallet-swap" : " Addition to the laravel-wallet library for quick setting of exchange rates" 
Original file line number Diff line number Diff line change @@ -37,11 +37,11 @@ parameters:
3737
3838		- 
3939			message :  " #^Method Bavix\\\\ Wallet\\\\ Internal\\\\ Service\\\\ StateService\\ :\\ :get\\ (\\ ) should return string\\ |null but returns mixed\\ .$#" 
40- 			count :  1 
40+ 			count :  2 
4141			path :  src/Internal/Service/StateService.php 
4242
4343		- 
44- 			message :  " #^Trying to invoke mixed but it's not a callable \\ .$#" 
44+ 			message :  " #^Parameter  \\ #2  \\ $callback of method Illuminate \\\\ Contracts \\\\ Cache \\\\ Repository \\ : \\ :rememberForever \\ ( \\ ) expects Closure, mixed given \\ .$#" 
4545			count :  1 
4646			path :  src/Internal/Service/StateService.php 
4747
Original file line number Diff line number Diff line change @@ -41,41 +41,42 @@ public function transaction(callable $callback): mixed
4141            );
4242        }
4343
44+         if  ($ level0 ) {
45+             return  $ callback
46+         }
47+ 
4448        $ this init  = true ;
4549
4650        try  {
47-             if  ($ level0 ) {
48-                 return  $ callback
49-             }
50- 
5151            $ this regulatorService ->purge ();
5252
5353            return  $ this connection ->transaction (function  () use  ($ callback
5454                $ result$ callback
5555                $ this init  = false ;
5656
57-                 if  ($ resultfalse  || (is_countable ($ resultcount ($ result0 )) {
58-                     $ this regulatorService ->purge ();
59-                 } else  {
60-                     $ this regulatorService ->approve ();
57+                 if  ($ resultfalse ) {
58+                     return  false ;
6159                }
6260
61+                 if  (is_countable ($ resultcount ($ result0 ) {
62+                     return  $ result
63+                 }
64+ 
65+                 $ this regulatorService ->approve ();
66+ 
6367                return  $ result
6468            });
6569        } catch  (RecordsNotFoundException ExceptionInterface $ exception
66-             $ this regulatorService ->purge ();
67-             $ this init  = false ;
68- 
6970            throw  $ exception
7071        } catch  (Throwable $ throwable
71-             $ this regulatorService ->purge ();
72-             $ this init  = false ;
73- 
7472            throw  new  TransactionFailedException (
7573                'Transaction failed. Message:  '  . $ throwablegetMessage (),
7674                ExceptionInterface::TRANSACTION_FAILED ,
7775                $ throwable
7876            );
77+         } finally  {
78+             $ this regulatorService ->purge ();
79+             $ this init  = false ;
7980        }
8081    }
8182}
Original file line number Diff line number Diff line change @@ -25,22 +25,24 @@ public function __construct(CacheFactory $cacheFactory)
2525
2626    public  function  fork (string  $ uuidcallable  $ valuevoid 
2727    {
28-         $ this forkCallables ->add (self ::PREFIX_FORK_CALL  . $ uuid$ value
28+         if  (! $ this forks ->has (self ::PREFIX_FORKS  . $ uuid
29+             $ this forkCallables ->put (self ::PREFIX_FORK_CALL  . $ uuid$ value
30+         }
2931    }
3032
3133    public  function  get (string  $ uuidstring 
3234    {
3335        $ callable$ this forkCallables ->pull (self ::PREFIX_FORK_CALL  . $ uuid
3436        if  ($ callablenull ) {
35-             $ this forks ->put (self ::PREFIX_FORKS  . $ uuid( string )  $ callable() );
37+             return   $ this forks ->rememberForever (self ::PREFIX_FORKS  . $ uuid$ callable
3638        }
3739
3840        return  $ this forks ->get (self ::PREFIX_FORKS  . $ uuid
3941    }
4042
4143    public  function  drop (string  $ uuidvoid 
4244    {
43-         $ this forkCallables ->delete (self ::PREFIX_FORK_CALL  . $ uuid
44-         $ this forks ->delete (self ::PREFIX_FORKS  . $ uuid
45+         $ this forkCallables ->forget (self ::PREFIX_FORK_CALL  . $ uuid
46+         $ this forks ->forget (self ::PREFIX_FORKS  . $ uuid
4547    }
4648}
Original file line number Diff line number Diff line change 1010
1111final  class  StorageService implements  StorageServiceInterface
1212{
13-     private  const  PREFIX  = 'wallet_strg :: ;
13+     private  const  PREFIX  = 'wallet_sg :: ;
1414
1515    public  function  __construct (
1616        private  MathServiceInterface $ mathService
Original file line number Diff line number Diff line change @@ -107,8 +107,8 @@ public function approve(): void
107107                $ event$ this balanceUpdatedEventAssembler ->create ($ wallet
108108                $ this dispatcherService ->dispatch ($ event
109109            }
110-         } finally  {
111110            $ this dispatcherService ->flush ();
111+         } finally  {
112112            $ this purge ();
113113        }
114114    }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments