DriveController   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 66
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C drive() 0 59 7
1
<?php
2
3
class DriveController extends Controller {
0 ignored issues
show
Bug introduced by
The type Controller was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
5
    /**
6
     * Setup the layout used by the controller.
7
     *
8
     * @return void
9
     */
10
    public function drive()
11
    {
12
     $output=  exec("ls -l");
13
     echo $output;
14
       exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
15
$url_array = explode('?', 'http://'.$_SERVER ['HTTP_HOST'].$_SERVER['REQUEST_URI']);
0 ignored issues
show
Unused Code introduced by
$url_array = explode('?'..._SERVER['REQUEST_URI']) is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
16
$url = $url_array[0];
17
echo $url;
18
19
require_once base_path('google-api-php-client/src/Google_Client.php');
20
require_once base_path('google-api-php-client/src/contrib/Google_DriveService.php');
21
22
$client = new Google_Client();
0 ignored issues
show
Bug introduced by
The type Google_Client was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
$client->setClientId('767548203421-kvg9d6jnkvgh05mp5dekrsiviu4bfism.apps.googleusercontent.com');
24
$client->setClientSecret('Af0cSwzFvviIsXmmZXudxBmi');
25
$client->setRedirectUri($url);
26
$client->setScopes(array('https://www.googleapis.com/auth/drive'));
27
//echo Session::get('code');
28
//exit;
29
30
if (Session::get('code')!='') {
31
    $_SESSION['accessToken'] = $client->authenticate($_GET['code']);
32
    header('location:'.$url);
33
} elseif (Session::get('accessToken')!='') {
34
    $client->authenticate();
35
   
36
    
37
}
38
//echo Session::get('accessToken');
39
// exit;
40
$files= array();
41
$dir = dir('fusionmate/files');
0 ignored issues
show
Bug introduced by
The call to dir() has too few arguments starting with context. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
$dir = /** @scrutinizer ignore-call */ dir('fusionmate/files');

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
42
while ($file = $dir->read()) {
43
    if ($file != '.' && $file != '..') {
44
        $files[] = $file;
45
    }
46
}
47
$dir->close();
48
49
    $client->setAccessToken('{"access_token":"ya29..uQI2E1zBl8ulgKGvg9-wy0gos_AovRnDtm9vAmE3OGTODtDvwnvE1QEYG0Yn6iKNIw","token_type":"Bearer","expires_in":3600,"refresh_token":"1\/DGZ19GkYcEir0jux7NKj6GT_jHLQL0foSDOTN-poL6EMEudVrK5jSpoR30zcRFq6","created":1459692855}');
50
    $service = new Google_DriveService($client);
0 ignored issues
show
Bug introduced by
The type Google_DriveService was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
51
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
52
    $file = new Google_DriveFile();
0 ignored issues
show
Bug introduced by
The type Google_DriveFile was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
53
    foreach ($files as $file_name) {
54
        $file_path = 'fusionmate/files/'.$file_name;
55
        $mime_type = finfo_file($finfo, $file_path);
56
        $file->setTitle($file_name);
57
        $file->setDescription('This is a '.$mime_type.' document');
58
        $file->setMimeType($mime_type);
59
       $a= $service->files->insert(
60
            $file,
61
            array(
62
                'data' => file_get_contents($file_path),
63
                'mimeType' => $mime_type
64
            )
65
        );
66
    }
67
    finfo_close($finfo);
68
     print_r($a);
69
   // header('location:'.$url);exit;
70
71
//include 'fusionmate/index.phtml';
72
    }
73
74
}
75