AssertInterface::interface_exist()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Sfneal\Testing\Utils\Traits;
4
5
use PHPUnit\Framework\Attributes\Test;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\Attributes\Test 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
7
trait AssertInterface
8
{
9
    #[Test]
10
    public function interface_exist()
11
    {
12
        $this->assertTrue(
0 ignored issues
show
Bug introduced by
It seems like assertTrue() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

12
        $this->/** @scrutinizer ignore-call */ 
13
               assertTrue(
Loading history...
13
            interface_exists($this->interface()),
0 ignored issues
show
Bug introduced by
The method interface() does not exist on Sfneal\Testing\Utils\Traits\AssertInterface. Did you maybe mean interface_is_implemented()? ( Ignorable by Annotation )

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

13
            interface_exists($this->/** @scrutinizer ignore-call */ interface()),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
14
            "The interface '{$this->interface()}' does not exist"
15
        );
16
    }
17
18
    #[Test]
19
    public function interface_is_implemented()
20
    {
21
        foreach ($this->classes() as $class) {
0 ignored issues
show
Bug introduced by
It seems like classes() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

21
        foreach ($this->/** @scrutinizer ignore-call */ classes() as $class) {
Loading history...
22
            $this->assertArrayHasKey($this->interface(), class_implements($class));
0 ignored issues
show
Bug introduced by
It seems like assertArrayHasKey() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

22
            $this->/** @scrutinizer ignore-call */ 
23
                   assertArrayHasKey($this->interface(), class_implements($class));
Loading history...
23
        }
24
    }
25
26
    #[Test]
27
    public function interface_methods_exist()
28
    {
29
        foreach ($this->methods() as $method) {
0 ignored issues
show
Bug introduced by
The method methods() does not exist on Sfneal\Testing\Utils\Traits\AssertInterface. Did you maybe mean interface_methods_exist()? ( Ignorable by Annotation )

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

29
        foreach ($this->/** @scrutinizer ignore-call */ methods() as $method) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
            $this->assertTrue(
31
                method_exists($this->interface(), $method),
32
                "The interface '{$this->interface()}' does not have the method '{$method}'"
33
            );
34
        }
35
    }
36
}
37