Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit b9747c4

Browse files
ovanschieStyleCIBot
authored andcommitted
Apply fixes from StyleCI
1 parent c20cb38 commit b9747c4

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/HostsFile.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ public function __construct($filePath = null)
3838
}
3939
}
4040

41-
if (!is_file($filePath) || !is_readable($filePath)) {
41+
if (! is_file($filePath) || ! is_readable($filePath)) {
4242
throw new Exception(sprintf('Unable to read file: %s', $filePath));
4343
}
4444

4545
$this->filePath = realpath($filePath);
46-
$this->bakPath = realpath($filePath) . '.bak';
46+
$this->bakPath = realpath($filePath).'.bak';
4747

4848
$this->readFile();
4949
}
5050

5151
/**
52-
* Return lines
52+
* Return lines.
5353
*
5454
* @return array
5555
*/
@@ -59,7 +59,7 @@ public function getLines()
5959
}
6060

6161
/**
62-
* Add a line
62+
* Add a line.
6363
*
6464
* @param $ip
6565
* @param $domain
@@ -70,11 +70,11 @@ public function getLines()
7070
*/
7171
public function addLine($ip, $domain, $aliases = '')
7272
{
73-
if (!filter_var($ip, FILTER_VALIDATE_IP)) {
73+
if (! filter_var($ip, FILTER_VALIDATE_IP)) {
7474
throw new Exception(sprintf("'%s', is not a valid ip", $ip));
7575
}
7676

77-
if (!filter_var($domain, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => "/^[a-zA-Z0-9\\.]*[a-zA-Z0-9]+?/"]])) {
77+
if (! filter_var($domain, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^[a-zA-Z0-9\\.]*[a-zA-Z0-9]+?/']])) {
7878
throw new Exception(sprintf("'%s', is not a valid domain", $domain));
7979
}
8080

@@ -91,7 +91,7 @@ public function addLine($ip, $domain, $aliases = '')
9191
*/
9292
public function removeLine($domain)
9393
{
94-
if (!filter_var($domain, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => "/^[a-zA-Z0-9\\.]*[a-zA-Z0-9]+?/"]])) {
94+
if (! filter_var($domain, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^[a-zA-Z0-9\\.]*[a-zA-Z0-9]+?/']])) {
9595
throw new Exception(sprintf("'%s', is not a valid domain", $domain));
9696
}
9797

@@ -101,7 +101,7 @@ public function removeLine($domain)
101101
}
102102

103103
/**
104-
* Save the file
104+
* Save the file.
105105
*
106106
* @param null $filePath
107107
*/
@@ -115,21 +115,21 @@ public function save($filePath = null)
115115
}
116116

117117
/**
118-
* Read the File
118+
* Read the File.
119119
*/
120120
protected function readFile()
121121
{
122122
$file = fopen($this->filePath, 'r');
123123

124-
while(($line = fgets($file)) !== false) {
124+
while (($line = fgets($file)) !== false) {
125125
$this->parseLine($line);
126126
}
127127

128128
fclose($file);
129129
}
130130

131131
/**
132-
* Parse a line
132+
* Parse a line.
133133
*
134134
* @param $line
135135
*/
@@ -138,7 +138,6 @@ protected function parseLine($line)
138138
$matches = $this->explodeLine($line);
139139

140140
if (isset($matches[1], $matches[2])) {
141-
142141
$ip = $matches[1];
143142
$domainLine = $this->explodeLine($matches[2]);
144143

@@ -152,7 +151,7 @@ protected function parseLine($line)
152151
}
153152

154153
/**
155-
* Explode entry by whitespace regex
154+
* Explode entry by whitespace regex.
156155
*
157156
* @param $line
158157
*
@@ -166,7 +165,7 @@ protected function explodeLine($line)
166165
}
167166

168167
/**
169-
* Write lines to the file
168+
* Write lines to the file.
170169
*
171170
* @param $filePath
172171
*
@@ -175,16 +174,16 @@ protected function explodeLine($line)
175174
*/
176175
protected function writeFile($filePath)
177176
{
178-
if (is_file($filePath) && !is_writable($filePath)) {
177+
if (is_file($filePath) && ! is_writable($filePath)) {
179178
throw new Exception(sprintf("File '%s' is not writable", $filePath));
180179
}
181180

182181
$file = fopen($filePath, 'w');
183182

184183
foreach ($this->lines as $domain => $attributes) {
185-
fwrite($file, $attributes['ip'] . "\t\t" . $domain ." " . $attributes['aliases'] . " \r\n");
184+
fwrite($file, $attributes['ip']."\t\t".$domain.' '.$attributes['aliases']." \r\n");
186185
}
187186

188187
fclose($file);
189188
}
190-
}
189+
}

0 commit comments

Comments
 (0)