Code Duplication    Length = 22-22 lines in 2 locations

lib/elFinderFlysystemGoogleDriveNetmount.php 1 location

@@ 80-101 (lines=22) @@
77
            $aToken = $options['access_token'];
78
79
            $rootObj = $service = null;
80
            if ($aToken) {
81
                try {
82
                    $client->setAccessToken($aToken);
83
                    if ($client->isAccessTokenExpired()) {
84
                        $aToken = array_merge($aToken, $client->fetchAccessTokenWithRefreshToken());
85
                        $client->setAccessToken($aToken);
86
                    }
87
                    $service = new \Google_Service_Drive($client);
88
                    $rootObj = $service->files->get('root');
89
90
                    $options['access_token'] = $aToken;
91
                    $this->session->set('GoogleDriveAuthParams', $options);
92
                } catch (Exception $e) {
93
                    $aToken = [];
94
                    $options['access_token'] = [];
95
                    if ($options['user'] !== 'init') {
96
                        $this->session->set('GoogleDriveAuthParams', $options);
97
98
                        return ['exit' => true, 'error' => elFinder::ERROR_REAUTH_REQUIRE];
99
                    }
100
                }
101
            }
102
103
            if ($options['user'] === 'init') {
104
                if (empty($options['url'])) {

lib/elFinderVolumeGoogleDrive.class.php 1 location

@@ 186-207 (lines=22) @@
183
            $aToken = $options['access_token'];
184
185
            $rootObj = $service = null;
186
            if ($aToken) {
187
                try {
188
                    $client->setAccessToken($aToken);
189
                    if ($client->isAccessTokenExpired()) {
190
                        $aToken = array_merge($aToken, $client->fetchAccessTokenWithRefreshToken());
191
                        $client->setAccessToken($aToken);
192
                    }
193
                    $service = new \Google_Service_Drive($client);
194
                    $rootObj = $service->files->get('root');
195
196
                    $options['access_token'] = $aToken;
197
                    $this->session->set('GoogleDriveAuthParams', $options);
198
                } catch (Exception $e) {
199
                    $aToken = [];
200
                    $options['access_token'] = [];
201
                    if ($options['user'] !== 'init') {
202
                        $this->session->set('GoogleDriveAuthParams', $options);
203
204
                        return ['exit' => true, 'error' => elFinder::ERROR_REAUTH_REQUIRE];
205
                    }
206
                }
207
            }
208
209
            if ($options['user'] === 'init') {
210
                if (empty($options['url'])) {