@@ -48,6 +48,27 @@ public function __construct(
4848 ?string $ storageApiToken ,
4949 array $ options = []
5050 ) {
51+ $ this ->validateConfiguration ($ internalQueueApiUrl , $ internalQueueToken , $ storageApiToken , $ options );
52+ if (!empty ($ options ['backoffMaxTries ' ])) {
53+ $ options ['backoffMaxTries ' ] = intval ($ options ['backoffMaxTries ' ]);
54+ } else {
55+ $ options ['backoffMaxTries ' ] = self ::DEFAULT_BACKOFF_RETRIES ;
56+ }
57+ if (empty ($ options ['userAgent ' ])) {
58+ $ options ['userAgent ' ] = self ::DEFAULT_USER_AGENT ;
59+ }
60+
61+ $ this ->guzzle = $ this ->initClient ($ internalQueueApiUrl , $ internalQueueToken , $ storageApiToken , $ options );
62+ $ this ->existingJobFactory = $ existingJobFactory ;
63+ $ this ->logger = $ logger ;
64+ }
65+
66+ private function validateConfiguration (
67+ string $ internalQueueApiUrl ,
68+ ?string $ internalQueueToken ,
69+ ?string $ storageApiToken ,
70+ array $ options
71+ ): void {
5172 $ validator = Validation::createValidator ();
5273 $ errors = $ validator ->validate ($ internalQueueApiUrl , [new Url ()]);
5374 if ($ internalQueueToken === null && $ storageApiToken === null ) {
@@ -68,12 +89,6 @@ public function __construct(
6889 }
6990 if (!empty ($ options ['backoffMaxTries ' ])) {
7091 $ errors ->addAll ($ validator ->validate ($ options ['backoffMaxTries ' ], [new Range (['min ' => 0 , 'max ' => 100 ])]));
71- $ options ['backoffMaxTries ' ] = intval ($ options ['backoffMaxTries ' ]);
72- } else {
73- $ options ['backoffMaxTries ' ] = self ::DEFAULT_BACKOFF_RETRIES ;
74- }
75- if (empty ($ options ['userAgent ' ])) {
76- $ options ['userAgent ' ] = self ::DEFAULT_USER_AGENT ;
7792 }
7893 if ($ errors ->count () !== 0 ) {
7994 $ messages = '' ;
@@ -83,9 +98,6 @@ public function __construct(
8398 }
8499 throw new ClientException ('Invalid parameters when creating client: ' . $ messages );
85100 }
86- $ this ->guzzle = $ this ->initClient ($ internalQueueApiUrl , $ internalQueueToken , $ storageApiToken , $ options );
87- $ this ->existingJobFactory = $ existingJobFactory ;
88- $ this ->logger = $ logger ;
89101 }
90102
91103 public function addJobUsage (string $ jobId , array $ usage ): void
0 commit comments