Completed
Push — master ( 5ae499...6e618b )
by smiley
03:01
created
src/LogOptions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,6 +23,6 @@
 block discarded – undo
23 23
  * @property string $logfileName
24 24
  * @property string $logfileExt
25 25
  */
26
-class LogOptions extends ImmutableSettingsAbstract{
26
+class LogOptions extends ImmutableSettingsAbstract {
27 27
 	use LogOptionsTrait;
28 28
 }
Please login to merge, or discard this patch.
src/Log.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use chillerlan\Logger\Output\LogOutputInterface;
16 16
 use Psr\Log\{LoggerInterface, LoggerTrait};
17 17
 
18
-class Log implements LoggerInterface{
18
+class Log implements LoggerInterface {
19 19
 	use LoggerTrait;
20 20
 
21 21
 	/**
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	/**
27 27
 	 * @return void
28 28
 	 */
29
-	public function __destruct(){
29
+	public function __destruct() {
30 30
 		$this->close();
31 31
 	}
32 32
 
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	public function close():Log{
39 39
 
40
-		if(!empty($this->logOutputInterfaces)){
41
-			foreach($this->logOutputInterfaces as $instanceName => $instance){
40
+		if (!empty($this->logOutputInterfaces)) {
41
+			foreach ($this->logOutputInterfaces as $instanceName => $instance) {
42 42
 				unset($this->logOutputInterfaces[$instanceName]);
43 43
 			}
44 44
 		}
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function getInstance(string $instanceName):LogOutputInterface{
68 68
 
69
-		if(!array_key_exists($instanceName, $this->logOutputInterfaces)){
69
+		if (!array_key_exists($instanceName, $this->logOutputInterfaces)) {
70 70
 			throw new LogException('invalid logger instance: '.$instanceName);
71 71
 		}
72 72
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function removeInstance(string $instanceName):Log{
83 83
 
84
-		if(!array_key_exists($instanceName, $this->logOutputInterfaces)){
84
+		if (!array_key_exists($instanceName, $this->logOutputInterfaces)) {
85 85
 			throw new LogException('invalid logger instance: '.$instanceName);
86 86
 		}
87 87
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	public function log($level, $message, array $context = [], string $instance = null):void{
105 105
 
106
-		foreach($this->logOutputInterfaces as $logger){
106
+		foreach ($this->logOutputInterfaces as $logger) {
107 107
 			$logger->log($level, $message, $context);
108 108
 		}
109 109
 
Please login to merge, or discard this patch.
src/Output/FileLog.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use chillerlan\Logger\LogException;
16 16
 use chillerlan\Traits\ImmutableSettingsInterface;
17 17
 
18
-class FileLog extends LogOutputAbstract{
18
+class FileLog extends LogOutputAbstract {
19 19
 
20 20
 	/**
21 21
 	 * @var bool|resource
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @throws \chillerlan\Logger\LogException
31 31
 	 */
32
-	public function __construct(ImmutableSettingsInterface $options = null){
32
+	public function __construct(ImmutableSettingsInterface $options = null) {
33 33
 		parent::__construct($options);
34 34
 
35
-		if(!is_writable($this->options->logfileDir)){
35
+		if (!is_writable($this->options->logfileDir)) {
36 36
 			throw new LogException('log file directory inaccessible');
37 37
 		}
38 38
 
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 	/**
45 45
 	 * @inheritdoc
46 46
 	 */
47
-	public function __destruct(){
47
+	public function __destruct() {
48 48
 		$this->close();
49 49
 
50
-		if(gettype($this->fh) === 'resource'){
50
+		if (gettype($this->fh) === 'resource') {
51 51
 			fclose($this->fh);
52 52
 		}
53 53
 	}
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	/**
56 56
 	 * @inheritdoc
57 57
 	 */
58
-	protected function __log(string $level, string $message, array $context = null){
58
+	protected function __log(string $level, string $message, array $context = null) {
59 59
 		fwrite($this->fh, $this->message($level, $message, $context));
60 60
 	}
61 61
 
Please login to merge, or discard this patch.
src/Output/DatabaseLog.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use chillerlan\Database\Connection;
16 16
 use chillerlan\Traits\ImmutableSettingsInterface;
17 17
 
18
-class DatabaseLog extends LogOutputAbstract{
18
+class DatabaseLog extends LogOutputAbstract {
19 19
 
20 20
 	/**
21 21
 	 * @var \chillerlan\Database\Connection
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param \chillerlan\Traits\ImmutableSettingsInterface|null $options
30 30
 	 * @param \chillerlan\Database\Connection    $db
31 31
 	 */
32
-	public function __construct(ImmutableSettingsInterface $options, Connection $db){
32
+	public function __construct(ImmutableSettingsInterface $options, Connection $db) {
33 33
 		$this->options = $options;
34 34
 		$this->db      = $db;
35 35
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * @inheritdoc
41 41
 	 */
42
-	protected function __log(string $level, string $message, array $context = []){
42
+	protected function __log(string $level, string $message, array $context = []) {
43 43
 
44 44
 		// TODO: $context, tests
45 45
 		$this->db->insert
Please login to merge, or discard this patch.
src/Output/ConsoleLog.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\Logger\Output;
14 14
 
15
-class ConsoleLog extends LogOutputAbstract{
15
+class ConsoleLog extends LogOutputAbstract {
16 16
 
17 17
 	/**
18 18
 	 * @inheritdoc
19 19
 	 */
20
-	protected function __log(string $level, string $message, array $context = null){
20
+	protected function __log(string $level, string $message, array $context = null) {
21 21
 		echo $this->message($level, $message, $context);
22 22
 	}
23 23
 
Please login to merge, or discard this patch.
src/Output/EmailLog.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 /**
19 19
  */
20
-class EmailLog extends LogOutputAbstract{
20
+class EmailLog extends LogOutputAbstract {
21 21
 
22 22
 	protected $mailer;
23 23
 
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 	 * @param \chillerlan\Traits\ImmutableSettingsInterface|null $options
29 29
 	 * @param \PHPMailer\PHPMailer\PHPMailer     $mailer
30 30
 	 */
31
-	public function __construct(ImmutableSettingsInterface $options, PHPMailer $mailer){
31
+	public function __construct(ImmutableSettingsInterface $options, PHPMailer $mailer) {
32 32
 		$this->options = $options;
33 33
 		$this->mailer  = $mailer;
34 34
 	}
35 35
 
36
-	protected function __log(string $level, string $message, array $context = null){
36
+	protected function __log(string $level, string $message, array $context = null) {
37 37
 		// TODO: Implement log() method.
38 38
 	}
39 39
 
Please login to merge, or discard this patch.
src/Output/LogOutputAbstract.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 /**
19 19
  *
20 20
  */
21
-abstract class LogOutputAbstract implements LogOutputInterface{
21
+abstract class LogOutputAbstract implements LogOutputInterface {
22 22
 
23 23
 	/**
24 24
 	 * @var \chillerlan\Logger\LogOptions
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @param \chillerlan\Traits\ImmutableSettingsInterface|null $options
32 32
 	 */
33
-	public function __construct(ImmutableSettingsInterface $options = null){
33
+	public function __construct(ImmutableSettingsInterface $options = null) {
34 34
 		$this->options = $options ?? new LogOptions;
35 35
 	}
36 36
 
37 37
 	/**
38 38
 	 * @inheritdoc
39 39
 	 */
40
-	public function __destruct(){
40
+	public function __destruct() {
41 41
 		$this->close();
42 42
 	}
43 43
 
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	 * @inheritdoc
62 62
 	 */
63
-	public function log(string $level, string $message, array $context = []){ // @todo: loglevel bitmask
64
-		if((array_key_exists($level, $this::LEVELS) && $this::LEVELS[$level] >= $this::LEVELS[$this->options->minLogLevel]) || (!array_key_exists($level, $this::LEVELS) && !empty($level))){
63
+	public function log(string $level, string $message, array $context = []) { // @todo: loglevel bitmask
64
+		if ((array_key_exists($level, $this::LEVELS) && $this::LEVELS[$level] >= $this::LEVELS[$this->options->minLogLevel]) || (!array_key_exists($level, $this::LEVELS) && !empty($level))) {
65 65
 			$this->__log($level, $message, $context);
66 66
 		}
67 67
 	}
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return string
75 75
 	 */
76
-	protected function message(string $level, string $message, array $context = null){
76
+	protected function message(string $level, string $message, array $context = null) {
77 77
 		return sprintf($this->options->consoleFormat, date($this->options->consoleDateFormat), $level, $message).PHP_EOL;
78 78
 	}
79 79
 
Please login to merge, or discard this patch.