IpUmbrella::input()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace KW\Models;
4
5
class IpUmbrella
6
{
7
8
    /**
9
    * @var array $ipobjekt array med info om ett ipnummer
10
    */
11
12
    public $ipobject = array(
13
        "number" => "",
14
        "valid" => false,
15
        "type" => "invalid",
16
        "domainname" => "none",
17
        "latitude" => 0,
18
        "longitude" => 0,
19
        "country" => "none",
20
        "city" => "none",
21
    );
22
23
    protected $ipValidate;
24
    protected $ipType;
25
    protected $ipDomainname;
26
    protected $ipCheckCoordinates;
27
28 2
    public function __construct($di)
29
    {
30 2
        $this->di = $di;
0 ignored issues
show
Bug Best Practice introduced by
The property di does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
31 2
        $this->ipValidate = new IpValidate($this->di);
0 ignored issues
show
Unused Code introduced by
The call to KW\Models\IpValidate::__construct() has too many arguments starting with $this->di. ( Ignorable by Annotation )

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

31
        $this->ipValidate = /** @scrutinizer ignore-call */ new IpValidate($this->di);

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. Please note the @ignore annotation hint above.

Loading history...
32 2
        $this->ipType = new IpType($this->di);
0 ignored issues
show
Unused Code introduced by
The call to KW\Models\IpType::__construct() has too many arguments starting with $this->di. ( Ignorable by Annotation )

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

32
        $this->ipType = /** @scrutinizer ignore-call */ new IpType($this->di);

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. Please note the @ignore annotation hint above.

Loading history...
33 2
        $this->ipDomainname = new IpDomainname($this->di);
0 ignored issues
show
Unused Code introduced by
The call to KW\Models\IpDomainname::__construct() has too many arguments starting with $this->di. ( Ignorable by Annotation )

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

33
        $this->ipDomainname = /** @scrutinizer ignore-call */ new IpDomainname($this->di);

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. Please note the @ignore annotation hint above.

Loading history...
34 2
        $this->ipCheckCoordinates = new IpCheckCoordinates($this->di);
35 2
    }
36
37
    /**
38
     * Check ip-type sdf saf sdf safd fsda
39
     *
40
     * @return array
41
     */
42 2
    public function input(string $ipnumber)
43
    {
44
45 2
        $this->ipobject["number"] = $ipnumber;
46 2
        $this->ipobject["valid"] = $this->ipValidate->validate($ipnumber);
47
48
49 2
        if ($this->ipobject["valid"]) {
50 1
            $this->ipobject["type"] = $this->ipType->ipType($ipnumber);
51 1
            $this->ipobject["domainname"] = $this->ipDomainname->ipDomainname($ipnumber);
52 1
            list($this->ipobject["latitude"], $this->ipobject["longitude"], $this->ipobject["country"], $this->ipobject["city"])
53 1
                = $this->ipCheckCoordinates->ipCheckCoordinates($ipnumber);
54
        }
55
56 2
        return $this->ipobject;
57
    }
58
}
59