LinesTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 41
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A info() 0 4 1
A error() 0 4 1
A success() 0 4 1
A warning() 0 4 1
A checkLine() 0 12 1
1
<?php
2
3
namespace DeGraciaMathieu\Clike\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use DeGraciaMathieu\Clike\Lines;
7
use DeGraciaMathieu\Clike\Contracts;
8
use DeGraciaMathieu\Clike\Lines\LineConstants;
9
10
class LinesTest extends TestCase {
11
12
    const CONTENT = 'line content';
13
14
    /** @test */
15
    public function info()
16
    {
17
        $this->checkLine(Lines\Info::class, LineConstants::INFO);
18
    }
19
20
    /** @test */
21
    public function error()
22
    {
23
        $this->checkLine(Lines\Error::class, LineConstants::ERROR);
24
    }
25
26
    /** @test */
27
    public function success()
28
    {
29
        $this->checkLine(Lines\Success::class, LineConstants::SUCCESS);
30
    }
31
32
    /** @test */
33
    public function warning()
34
    {
35
        $this->checkLine(Lines\Warning::class, LineConstants::WARNING);
36
    }
37
38
    protected function checkLine($line, $type)
39
    {
40
        $line = new $line(self::CONTENT);
41
42
        $expectedArray = [
43
            'type' => $type,
44
            'content' => self::CONTENT,
45
        ];
46
47
        $this->isInstanceOf(Contracts\Line::class, $line);
0 ignored issues
show
Unused Code introduced by
The call to LinesTest::isInstanceOf() has too many arguments starting with $line.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
48
        $this->assertEquals($expectedArray, $line->read());
49
    }
50
}
51