Conditions | 5 |
Paths | 5 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 5.9256 |
Changes | 0 |
1 | <?php |
||
32 | 1 | public function __construct($hostname = '', $port = 9100) |
|
33 | { |
||
34 | 1 | parent::__construct(); |
|
35 | if (empty($hostname)) { |
||
36 | throw new InvalidArgumentException("A hostname or a valid IP must be passed."); |
||
37 | 1 | } |
|
38 | if (empty($port) || ! is_numeric($port)) { |
||
39 | $port = 9100; |
||
40 | 1 | } |
|
41 | 1 | $errno = 0; |
|
42 | 1 | $errstr = ''; |
|
43 | 1 | $this->resource = @fsockopen($hostname, $port, $errno, $errstr); |
|
44 | 1 | if ($this->resource === false) { |
|
45 | throw new RuntimeException("Cannot initialise NetworkPrintConnector: " . $errstr); |
||
46 | } |
||
47 | } |
||
48 | } |
||
49 |