@@ -22,18 +22,34 @@ class ExecutionOutsideLockException extends LockReleaseException
2222 * Creates a new instance of the ExecutionOutsideLockException class.
2323 *
2424 * @param float $elapsedTime Total elapsed time of the synchronized code
25- * callback execution.
26- * @param int $timeout The lock timeout in seconds.
25+ * callback execution.
26+ * @param float $timeout The lock timeout in seconds.
2727 * @return self Execution outside lock exception.
2828 */
29- public static function create (float $ elapsedTime , int $ timeout ): self
29+ public static function create (float $ elapsedTime , float $ timeout ): self
3030 {
31+ $ elapsedTimeStr = (string ) round ($ elapsedTime , 6 );
32+ if (\is_finite ($ elapsedTime ) && strpos ($ elapsedTimeStr , '. ' ) === false ) {
33+ $ elapsedTimeStr .= '.0 ' ;
34+ }
35+
36+ $ timeoutStr = (string ) round ($ timeout , 6 );
37+ if (\is_finite ($ timeout ) && strpos ($ timeoutStr , '. ' ) === false ) {
38+ $ timeoutStr .= '.0 ' ;
39+ }
40+
41+ $ overTime = round ($ elapsedTime , 6 ) - round ($ timeout , 6 );
42+ $ overTimeStr = (string ) round ($ overTime , 6 );
43+ if (\is_finite ($ timeout ) && strpos ($ overTimeStr , '. ' ) === false ) {
44+ $ overTimeStr .= '.0 ' ;
45+ }
46+
3147 return new self (\sprintf (
32- 'The code executed for %.2F seconds. But the timeout is %d ' .
33- 'seconds. The last %.2F seconds were executed outside of the lock. ' ,
34- $ elapsedTime ,
35- $ timeout ,
36- $ elapsedTime - $ timeout
48+ 'The code executed for %s seconds. But the timeout is %s ' .
49+ 'seconds. The last %s seconds were executed outside of the lock. ' ,
50+ $ elapsedTimeStr ,
51+ $ timeoutStr ,
52+ $ overTimeStr
3753 ));
3854 }
3955}
0 commit comments