FindInvalidViewCalls   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 9 2
A __construct() 0 4 1
A getFunctionName() 0 3 1
1
<?php
2
3
namespace Juddling\RouteChecker;
4
5
use Illuminate\Support\Collection;
6
use Illuminate\View\FileViewFinder;
0 ignored issues
show
Bug introduced by
The type Illuminate\View\FileViewFinder 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 InvalidArgumentException;
8
9
class FindInvalidViewCalls extends FindInvalid
10
{
11
    /** @var Collection */
12
    protected $viewPaths;
13
    /** @var string $nameOfArgument */
14
    protected $nameOfArgument = 'View Path';
15
    /** @var FileViewFinder $views */
16
    protected $viewFinder;
17
18
    public function __construct()
19
    {
20
        $this->viewFinder = app('view.finder');
0 ignored issues
show
Bug introduced by
The function app 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
        $this->viewFinder = /** @scrutinizer ignore-call */ app('view.finder');
Loading history...
21
        parent::__construct();
22
    }
23
24
    protected function getFunctionName()
25
    {
26
        return 'view';
27
    }
28
29
    protected function check(string $viewPath): bool
30
    {
31
        try {
32
            $this->viewFinder->find($viewPath);
33
        } catch (InvalidArgumentException $e) {
34
            return false;
35
        }
36
37
        return true;
38
    }
39
}
40