GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( cc25ac...3ef2ca )
by Baptiste
03:24 queued 49s
created

NamedMethodStrategyTest.php$0 ➔ testSupports()   A

Complexity

Conditions 1

Size

Total Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 34
rs 9.376
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A NamedMethodStrategyTest.php$0 ➔ someLongProperty() 0 2 1
A NamedMethodStrategyTest.php$0 ➔ foo() 0 2 1
A NamedMethodStrategyTest.php$0 ➔ b() 0 2 1
A NamedMethodStrategyTest.php$0 ➔ a() 0 2 1
A NamedMethodStrategyTest.php$0 ➔ bar() 0 2 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Tests\Innmind\Reflection\ExtractionStrategy;
5
6
use Innmind\Reflection\{
7
    ExtractionStrategy\NamedMethodStrategy,
8
    ExtractionStrategy,
9
    Exception\LogicException,
10
};
11
use Fixtures\Innmind\Reflection\Foo;
12
use PHPUnit\Framework\TestCase;
13
14
class NamedMethodStrategyTest extends TestCase
15
{
16
    public function testInterface()
17
    {
18
        $this->assertInstanceOf(
19
            ExtractionStrategy::class,
20
            new NamedMethodStrategy
21
        );
22
    }
23
24
    public function testSupports()
25
    {
26
        $o = new class {
27
            public $c;
28
29
            public function a()
30
            {
31
            }
32
33
            public function someLongProperty()
34
            {
35
            }
36
37
            public function b($b)
0 ignored issues
show
Unused Code introduced by
The parameter $b 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

37
            public function b(/** @scrutinizer ignore-unused */ $b)

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...
38
            {
39
            }
40
41
            private function foo()
42
            {
43
            }
44
45
            private function bar()
46
            {
47
            }
48
        };
49
50
        $s = new NamedMethodStrategy;
51
52
        $this->assertTrue($s->supports($o, 'a'));
53
        $this->assertTrue($s->supports($o, 'some_long_property'));
54
        $this->assertFalse($s->supports($o, 'b'));
55
        $this->assertFalse($s->supports($o, 'c'));
56
        $this->assertFalse($s->supports($o, 'foo'));
57
        $this->assertFalse($s->supports($o, 'bar'));
58
    }
59
60
    public function testThrowWhenExtractingUnsuppportedProperty()
61
    {
62
        $o = new \stdClass;
63
        $s = new NamedMethodStrategy;
64
65
        $this->expectException(LogicException::class);
66
67
        $s->extract($o, 'a');
68
    }
69
70
    public function testExtract()
71
    {
72
        $o = new class {
73
            public function a()
74
            {
75
                return 42;
76
            }
77
78
            public function someLongProperty()
79
            {
80
                return 66;
81
            }
82
        };
83
        $s = new NamedMethodStrategy;
84
85
        $this->assertSame(42, $s->extract($o, 'a'));
86
        $this->assertSame(66, $s->extract($o, 'some_long_property'));
87
    }
88
89
    public function testExtractInheritedMethod()
90
    {
91
        $object = new class extends Foo {};
92
        $strategy = new NamedMethodStrategy;
93
94
        $this->assertSame(42, $strategy->extract($object, 'someProperty'));
95
    }
96
}
97