PHPClientAddrTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 17
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testOne() 0 7 1
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
5
class PHPClientAddrTest extends TestCase
6
{
7
    protected function setUp()
8
    {
9
        $this->cliaddr = new PHPTools\PHPClientAddr\PHPClientAddr();
0 ignored issues
show
Bug introduced by
The property cliaddr does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
10
11
        $this->assertInstanceOf('PHPTools\PHPClientAddr\PHPClientAddr', $this->cliaddr);
12
    }
13
14
    public function testOne()
15
    {
16
        $this->assertInternalType('string', $this->cliaddr->ip);
17
        $this->assertInternalType('string', $this->cliaddr->hostname);
18
        $this->assertTrue(!!filter_var($this->cliaddr->ip, FILTER_VALIDATE_IP));
19
20
    }
21
}
22