1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-07-31 10:20:14 +02:00

Coding style fixes, refs #720

This commit is contained in:
Jordi Boggiano
2016-05-26 18:16:46 +01:00
parent 8a379a3166
commit 3d7842ec1e
2 changed files with 10 additions and 30 deletions

View File

@@ -67,8 +67,12 @@ class ProcessHandler extends AbstractProcessingHandler
*/
public function __construct($command, $level = Logger::DEBUG, $bubble = true, $cwd = null)
{
$this->guardAgainstInvalidCommand($command);
$this->guardAgainstInvalidCwd($cwd);
if (empty($command) || is_string($command) === false) {
throw new \InvalidArgumentException('The command argument must be a non-empty string.');
}
if ($cwd !== null && (empty($cwd) || is_string($cwd) === false)) {
throw new \InvalidArgumentException('The optional CWD argument must be a non-empty string, if any.');
}
parent::__construct($level, $bubble);
@@ -76,30 +80,6 @@ class ProcessHandler extends AbstractProcessingHandler
$this->cwd = $cwd;
}
/**
* @param string $command
* @throws \InvalidArgumentException
* @return void
*/
private function guardAgainstInvalidCommand($command)
{
if (empty($command) || is_string($command) === false) {
throw new \InvalidArgumentException('The command argument must be a non-empty string.');
}
}
/**
* @param string $cwd
* @throws \InvalidArgumentException
* @return void
*/
private function guardAgainstInvalidCwd($cwd)
{
if ($cwd !== null && (empty($cwd) || is_string($cwd) === false)) {
throw new \InvalidArgumentException('The optional CWD argument must be a non-empty string, if any.');
}
}
/**
* Writes the record down to the log of the implementing handler
*
@@ -156,7 +136,6 @@ class ProcessHandler extends AbstractProcessingHandler
*/
private function handleStartupErrors()
{
$selected = $this->selectErrorStream();
if (false === $selected) {
throw new \UnexpectedValueException('Something went wrong while selecting a stream.');
@@ -180,6 +159,7 @@ class ProcessHandler extends AbstractProcessingHandler
{
$empty = [];
$errorPipes = [$this->pipes[2]];
return stream_select($errorPipes, $empty, $empty, 1);
}
@@ -203,7 +183,7 @@ class ProcessHandler extends AbstractProcessingHandler
*/
protected function writeProcessInput($string)
{
fwrite($this->pipes[0], (string)$string);
fwrite($this->pipes[0], (string) $string);
}
/**
@@ -216,7 +196,7 @@ class ProcessHandler extends AbstractProcessingHandler
fclose($pipe);
}
proc_close($this->process);
$this->process = null;
}
$this->process = null;
}
}

View File

@@ -11,7 +11,7 @@
namespace Monolog\Handler;
use Monolog\TestCase;
use Monolog\Test\TestCase;
use Monolog\Logger;
class ProcessHandlerTest extends TestCase