Breaker   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFilePath() 0 5 1
A __callStatic() 0 9 4
A getRandomLine() 0 9 2
1
<?php
2
3
namespace DeGraciaMathieu\Nero;
4
5
class Breaker {
6
7
    /**
8
     * Destroy your application
9
     * @param  string $name
10
     * @param  mixed $arguments
11
     * @return exit
0 ignored issues
show
Bug introduced by
The type DeGraciaMathieu\Nero\exit 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...
12
     */
13
    public static function __callStatic($name, $arguments)
14
    {
15
        $file = isset($arguments[0]) ? $arguments[0] : self::getFilePath();
16
17
        $line = isset($arguments[1]) ? $arguments[1] : self::getRandomLine($file);
18
19
        $parameter = isset($arguments[2]) ? $arguments[2] : null;
20
21
        call_user_func_array([new Errors, $name], [$file, $line, $parameter]);
22
    }
23
24
    /**
25
     * get the path of the calling page
26
     * @return string
27
     */
28
    protected static function getFilePath()
29
    {
30
        $backtrace = debug_backtrace();
31
32
        return $backtrace[1]['file'];
33
    }
34
35
    /**
36
     * random number
37
     * @param string $path
38
     * @return integer
39
     */
40
    protected static function getRandomLine($path)
41
    {
42
        $numberMax = 200;
43
44
        if (file_exists($path)) {
45
            $numberMax = count(file($path));
0 ignored issues
show
Bug introduced by
It seems like file($path) can also be of type false; however, parameter $var of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

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

45
            $numberMax = count(/** @scrutinizer ignore-type */ file($path));
Loading history...
46
        }
47
48
        return rand(1, $numberMax);
49
    }   
50
}
51