Passed
Push — master ( 1ddf5f...c8f01d )
by Stephen
22:47 queued 22:12
created

AssertInterface::interface_is_implemented()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Sfneal\Testing\Utils\Traits;
4
5
trait AssertInterface
6
{
7
    /** @test */
8
    public function interface_exist()
9
    {
10
        $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

10
        $this->/** @scrutinizer ignore-call */ 
11
               assertTrue(
Loading history...
11
            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

11
            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...
12
            "The interface '{$this->interface()}' does not exist"
13
        );
14
    }
15
16
    /** @test */
17
    public function interface_is_implemented()
18
    {
19
        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

19
        foreach ($this->/** @scrutinizer ignore-call */ classes() as $class) {
Loading history...
20
            $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

20
            $this->/** @scrutinizer ignore-call */ 
21
                   assertArrayHasKey($this->interface(), class_implements($class));
Loading history...
21
        }
22
    }
23
24
    /** @test */
25
    public function interface_methods_exist()
26
    {
27
        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

27
        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...
28
            $this->assertTrue(
29
                method_exists($this->interface(), $method),
30
                "The interface '{$this->interface()}' does not have the method '{$method}'"
31
            );
32
        }
33
    }
34
}
35