Validator::isValidMethod()   A
last analyzed

Complexity

Conditions 3
Paths 5

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
c 0
b 0
f 0
nc 5
nop 2
dl 0
loc 16
rs 9.9666
1
<?php
2
3
namespace OckCyp\CoversValidator\Validator;
4
5
use PHPUnit\Framework\CodeCoverageException;
6
use PHPUnit\Util\Test;
7
8
class Validator
9
{
10
    /**
11
     * Check if the method has valid @covers and @uses tags
12
     *
13
     * @param string $class
14
     * @param string $method
15
     *
16
     * @return bool
17
     */
18
    public static function isValidMethod($class, $method)
19
    {
20
        try {
21
            if (class_exists('PHPUnit\Metadata\Api\CodeCoverage', true)) {
22
                // PHPUnit 10+
23
                (new \PHPUnit\Metadata\Api\CodeCoverage())
0 ignored issues
show
Bug introduced by
The type PHPUnit\Metadata\Api\CodeCoverage 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...
24
                    ->linesToBeCovered($class, $method);
25
            } else {
26
                // PHPUnit < 10
27
                Test::getLinesToBeCovered($class, $method);
28
            }
29
        } catch (CodeCoverageException $e) {
30
            return false;
31
        }
32
33
        return true;
34
    }
35
}
36