Passed
Push — master ( 668ff3...1f2ae2 )
by Yash
03:26
created

Client::drive()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Webelightdev\LaravelDbBackup\BackupStorage\GoogleDrive;
4
5
use Google_Client;
6
use Google_Service_Drive;
7
8
class Client
9
{
10
    protected $client_id;
11
    protected $client_secret;
12
    protected $redirect_uri;
13
    protected $scopes;
14
    protected $access_type;
15
16
    public function __construct()
17
    {
18
        $config_path = 'dbbackup.storage.disk.googledrive.';
19
20
        $this->client_id = config($config_path.'client_id');
21
        $this->client_secret = config($config_path.'client_secret');
22
        $this->redirect_uri = config($config_path.'redirect_uri');
23
        $this->scopes = config($config_path.'scopes');
24
        $this->access_type = config($config_path.'access_type');
25
    }
26
27
    public function client()
28
    {
29
        $client = new Google_Client();
30
        $client->setClientId($this->client_id);
31
        $client->setClientSecret($this->client_secret);
32
        $client->setRedirectUri($this->redirect_uri);
33
        $client->setScopes([$this->scopes]);
34
        $client->setAccessType($this->access_type);
35
36
        return $client;
37
    }
38
39
    public function drive($client)
40
    {
41
        $drive = new Google_Service_Drive($client);
42
        return $drive;
43
    }
44
}
45