TodoBarController::getScripts()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
nc 1
nop 0
dl 0
loc 2
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
3
namespace TPaksu\TodoBar\Controllers;
4
5
use App\Http\Controllers\Controller;
0 ignored issues
show
Bug introduced by
The type App\Http\Controllers\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...
6
use Illuminate\Http\Response;
0 ignored issues
show
Bug introduced by
The type Illuminate\Http\Response 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...
7
use Illuminate\Support\Facades\View;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\Facades\View 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...
8
9
class TodoBarController extends Controller {
10
11
    public function getScripts() {
12
        return "<script type='text/javascript'>" . file_get_contents($this->assets_path("todobar.js")) . "</script>";
13
    }
14
15
    public function getDrawer() {
16
        return View::make("laravel-todobar::todobar");
17
    }
18
19
    public function getStyles() {
20
        $dark_mode = config("todobar.dark_mode", false);
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

20
        $dark_mode = /** @scrutinizer ignore-call */ config("todobar.dark_mode", false);
Loading history...
21
        $file = "todobar.css";
22
        if ($dark_mode) {
23
            $file = "todobar-dark.css";
24
        }
25
        $path = $this->assets_path($file);
26
        return "<style>" . file_get_contents($path) . "</style>";
27
    }
28
29
    public function getInjection()
30
    {
31
        return $this->getStyles() . $this->getDrawer() . $this->getScripts();
32
    }
33
34
    public function inject(Response $response) {
35
        $response->setContent(str_replace("</body>", "</body>" . $this->getInjection(), $response->getContent()));
36
    }
37
38
    public function assets_path($file)
39
    {
40
        return implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "assets", $file]);
41
    }
42
}
43