Issues (44)

src/Leniency/AbstractLeniency.php (4 issues)

1
<?php
2
3
namespace libphonenumber\Leniency;
4
5
use libphonenumber\PhoneNumber;
6
use libphonenumber\PhoneNumberUtil;
7
8
abstract class AbstractLeniency
9
{
10
    /**
11
     * Integer level to compare 'ENUMs'
12
     * @var int
13
     */
14
    protected static $level;
15
16
    /**
17
     * Returns true if $number is a verified number according to this leniency
18
     *
19
     * @param PhoneNumber $number
20
     * @param string $candidate
21
     * @param PhoneNumberUtil $util
22
     * @return bool
23
     * @codeCoverageIgnore
24
     */
25
    public static function verify(PhoneNumber $number, $candidate, PhoneNumberUtil $util)
0 ignored issues
show
The parameter $number is not used and could be removed. ( Ignorable by Annotation )

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

25
    public static function verify(/** @scrutinizer ignore-unused */ PhoneNumber $number, $candidate, PhoneNumberUtil $util)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $candidate is not used and could be removed. ( Ignorable by Annotation )

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

25
    public static function verify(PhoneNumber $number, /** @scrutinizer ignore-unused */ $candidate, PhoneNumberUtil $util)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $util is not used and could be removed. ( Ignorable by Annotation )

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

25
    public static function verify(PhoneNumber $number, $candidate, /** @scrutinizer ignore-unused */ PhoneNumberUtil $util)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
    {
27
        // This can not be called directly
28
        throw new \BadMethodCallException;
29
    }
30
31
    /**
32
     * Compare against another Leniency
33
     * @param AbstractLeniency $leniency
34
     * @return int
35
     */
36 180
    public static function compareTo(AbstractLeniency $leniency)
37
    {
38 180
        return static::getLevel() - $leniency::getLevel();
39
    }
40
41 180
    protected static function getLevel()
42
    {
43 180
        if (static::$level === null) {
0 ignored issues
show
The condition static::level === null is always false.
Loading history...
44
            throw new \RuntimeException('$level should be defined');
45
        }
46
47 180
        return static::$level;
48
    }
49
50 172
    public function __toString()
51
    {
52 172
        return str_replace('libphonenumber\\Leniency\\', '', get_class($this));
53
    }
54
}
55