@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\TaskHelper; |
4 | 4 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param int $status One of the Task::STATUS_* constants |
22 | 22 | * @param string[] $errors |
23 | 23 | */ |
24 | - public function __construct( int $status, array $errors = [] ) { |
|
24 | + public function __construct ( int $status, array $errors = [ ] ) { |
|
25 | 25 | $this->status = $status; |
26 | 26 | $this->errors = $errors; |
27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @return int |
31 | 31 | */ |
32 | - public function getStatus(): int { |
|
32 | + public function getStatus (): int { |
|
33 | 33 | return $this->status; |
34 | 34 | } |
35 | 35 | |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | * @return string[] |
38 | 38 | * @suppress PhanUnreferencedPublicMethod |
39 | 39 | */ |
40 | - public function getErrors(): array { |
|
40 | + public function getErrors (): array { |
|
41 | 41 | return $this->errors; |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @param TaskResult $that |
46 | 46 | */ |
47 | - public function merge( TaskResult $that ): void { |
|
47 | + public function merge ( TaskResult $that ): void { |
|
48 | 48 | $this->status |= $that->status; |
49 | 49 | $this->errors = array_merge( $this->errors, $that->errors ); |
50 | 50 | } |
@@ -52,15 +52,15 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @return string |
54 | 54 | */ |
55 | - public function __toString(): string { |
|
55 | + public function __toString (): string { |
|
56 | 56 | if ( $this->isOK() ) { |
57 | 57 | $stat = 'OK'; |
58 | 58 | $errs = "\tNo errors."; |
59 | 59 | } else { |
60 | 60 | $stat = 'ERROR'; |
61 | - $formattedErrs = []; |
|
61 | + $formattedErrs = [ ]; |
|
62 | 62 | foreach ( $this->errors as $err ) { |
63 | - $formattedErrs[] = "\t - $err"; |
|
63 | + $formattedErrs[ ] = "\t - $err"; |
|
64 | 64 | } |
65 | 65 | $errs = implode( "\n", $formattedErrs ); |
66 | 66 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return bool |
74 | 74 | */ |
75 | - public function isOK(): bool { |
|
75 | + public function isOK (): bool { |
|
76 | 76 | return ( $this->status | self::STATUS_GOOD ) === self::STATUS_GOOD; |
77 | 77 | } |
78 | 78 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme; |
4 | 4 | |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | /** @var self */ |
12 | 12 | private static $instance; |
13 | 13 | /** @var string[] */ |
14 | - private $opts = []; |
|
14 | + private $opts = [ ]; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Use self::init() and self::getInstance() |
18 | 18 | */ |
19 | - private function __construct() { |
|
19 | + private function __construct () { |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param string[] $confValues |
26 | 26 | * @throws ConfigException |
27 | 27 | */ |
28 | - public static function init( array $confValues ): void { |
|
28 | + public static function init ( array $confValues ): void { |
|
29 | 29 | if ( self::$instance ) { |
30 | 30 | throw new ConfigException( 'Config was already initialized' ); |
31 | 31 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param string $key |
45 | 45 | * @param mixed $value |
46 | 46 | */ |
47 | - protected function set( string $key, $value ): void { |
|
47 | + protected function set ( string $key, $value ): void { |
|
48 | 48 | $this->opts[ $key ] = $value; |
49 | 49 | } |
50 | 50 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @return self |
55 | 55 | * @throws ConfigException |
56 | 56 | */ |
57 | - public static function getInstance(): self { |
|
57 | + public static function getInstance (): self { |
|
58 | 58 | if ( !self::$instance ) { |
59 | 59 | throw new ConfigException( 'Config not yet initialized' ); |
60 | 60 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return mixed |
69 | 69 | * @throws ConfigException |
70 | 70 | */ |
71 | - public function get( string $opt ) { |
|
71 | + public function get ( string $opt ) { |
|
72 | 72 | if ( !isset( $this->opts[ $opt ] ) ) { |
73 | 73 | throw new ConfigException( "Config option '$opt' not set." ); |
74 | 74 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Logger; |
4 | 4 | |
@@ -11,5 +11,5 @@ discard block |
||
11 | 11 | /** |
12 | 12 | * Flush the buffer |
13 | 13 | */ |
14 | - public function flush(): void; |
|
14 | + public function flush (): void; |
|
15 | 15 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Logger; |
4 | 4 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @param string $level |
12 | 12 | * @return int |
13 | 13 | */ |
14 | - protected function levelToInt( string $level ): int { |
|
14 | + protected function levelToInt ( string $level ): int { |
|
15 | 15 | // Order matters |
16 | 16 | $mapping = [ |
17 | 17 | LogLevel::DEBUG, |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $message |
32 | 32 | * @return string |
33 | 33 | */ |
34 | - protected function getFormattedMessage( string $level, string $message ): string { |
|
34 | + protected function getFormattedMessage ( string $level, string $message ): string { |
|
35 | 35 | return sprintf( '%s [%s] - %s', date( 'd M H:i:s' ), $level, $message ); |
36 | 36 | } |
37 | 37 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Logger; |
4 | 4 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param string $summary |
30 | 30 | * @param string $minlevel |
31 | 31 | */ |
32 | - public function __construct( Page $logPage, string $summary, $minlevel = LogLevel::INFO ) { |
|
32 | + public function __construct ( Page $logPage, string $summary, $minlevel = LogLevel::INFO ) { |
|
33 | 33 | $this->minLevel = $this->levelToInt( $minlevel ); |
34 | 34 | $this->logPage = $logPage; |
35 | 35 | $this->summary = $summary; |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | * @param mixed[] $context |
41 | 41 | * @suppress PhanUnusedPublicMethodParameter |
42 | 42 | */ |
43 | - public function log( $level, $message, array $context = [] ): void { |
|
43 | + public function log ( $level, $message, array $context = [ ] ): void { |
|
44 | 44 | if ( $this->levelToInt( $level ) >= $this->minLevel ) { |
45 | - $this->buffer[] = $this->getFormattedMessage( $level, $message ); |
|
45 | + $this->buffer[ ] = $this->getFormattedMessage( $level, $message ); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @return string |
51 | 51 | */ |
52 | - protected function getOutput(): string { |
|
52 | + protected function getOutput (): string { |
|
53 | 53 | $line = str_repeat( '-', 80 ); |
54 | 54 | return "\n\n" . implode( "\n", $this->buffer ) . "\n$line\n\n"; |
55 | 55 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | /** |
58 | 58 | * @inheritDoc |
59 | 59 | */ |
60 | - public function flush(): void { |
|
60 | + public function flush (): void { |
|
61 | 61 | if ( $this->buffer ) { |
62 | 62 | $this->logPage->edit( [ |
63 | 63 | 'appendtext' => $this->getOutput(), |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Logger; |
4 | 4 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @param IFlushingAwareLogger ...$loggers |
16 | 16 | */ |
17 | - public function __construct( IFlushingAwareLogger ...$loggers ) { |
|
17 | + public function __construct ( IFlushingAwareLogger ...$loggers ) { |
|
18 | 18 | $this->loggers = $loggers; |
19 | 19 | } |
20 | 20 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param mixed[] $context |
24 | 24 | * @suppress PhanUnusedPublicMethodParameter |
25 | 25 | */ |
26 | - public function log( $level, $message, array $context = [] ): void { |
|
26 | + public function log ( $level, $message, array $context = [ ] ): void { |
|
27 | 27 | foreach ( $this->loggers as $logger ) { |
28 | 28 | $logger->log( $level, $message ); |
29 | 29 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @inheritDoc |
34 | 34 | */ |
35 | - public function flush(): void { |
|
35 | + public function flush (): void { |
|
36 | 36 | foreach ( $this->loggers as $logger ) { |
37 | 37 | $logger->flush(); |
38 | 38 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Logger; |
4 | 4 | |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @param string $minlevel |
19 | 19 | */ |
20 | - public function __construct( $minlevel = LogLevel::INFO ) { |
|
20 | + public function __construct ( $minlevel = LogLevel::INFO ) { |
|
21 | 21 | $this->minLevel = $this->levelToInt( $minlevel ); |
22 | 22 | } |
23 | 23 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param mixed[] $context |
27 | 27 | * @suppress PhanUnusedPublicMethodParameter |
28 | 28 | */ |
29 | - public function log( $level, $message, array $context = [] ): void { |
|
29 | + public function log ( $level, $message, array $context = [ ] ): void { |
|
30 | 30 | if ( $this->levelToInt( $level ) >= $this->minLevel ) { |
31 | 31 | echo $this->getFormattedMessage( $level, $message ) . "\n"; |
32 | 32 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @inheritDoc |
37 | 37 | */ |
38 | - public function flush(): void { |
|
38 | + public function flush (): void { |
|
39 | 39 | // Everything else is printed immediately |
40 | 40 | echo "\n" . str_repeat( '-', 80 ) . "\n\n"; |
41 | 41 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Message; |
4 | 4 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @param string $value |
25 | 25 | */ |
26 | - public function __construct( string $value ) { |
|
26 | + public function __construct ( string $value ) { |
|
27 | 27 | $this->value = $value; |
28 | 28 | } |
29 | 29 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @phan-param array<string,int|string> $args |
33 | 33 | * @return self |
34 | 34 | */ |
35 | - public function params( array $args ): self { |
|
35 | + public function params ( array $args ): self { |
|
36 | 36 | $this->value = strtr( $this->value, $args ); |
37 | 37 | return $this; |
38 | 38 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @return string |
42 | 42 | */ |
43 | - public function text(): string { |
|
43 | + public function text (): string { |
|
44 | 44 | $this->parsePlurals(); |
45 | 45 | return $this->value; |
46 | 46 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * Replace {{$plur|<amount>|sing|plur}} |
50 | 50 | */ |
51 | - protected function parsePlurals(): void { |
|
51 | + protected function parsePlurals (): void { |
|
52 | 52 | $reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!'; |
53 | 53 | |
54 | 54 | if ( preg_match( $reg, $this->value ) === 0 ) { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @return string |
62 | 62 | */ |
63 | 63 | static function ( array $matches ): string { |
64 | - return (int)$matches['amount'] > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] ); |
|
64 | + return (int)$matches[ 'amount' ] > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] ); |
|
65 | 65 | }, |
66 | 66 | $this->value |
67 | 67 | ); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param string $timeString Full format, e.g. "15 aprile 2019 18:27" |
74 | 74 | * @return int |
75 | 75 | */ |
76 | - public static function getTimestampFromLocalTime( string $timeString ): int { |
|
76 | + public static function getTimestampFromLocalTime ( string $timeString ): int { |
|
77 | 77 | $englishTime = str_ireplace( |
78 | 78 | array_values( self::MONTHS ), |
79 | 79 | array_keys( self::MONTHS ), |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | * @param string $emptyText |
93 | 93 | * @return string |
94 | 94 | */ |
95 | - public static function commaList( array $data, string $emptyText = 'nessuno' ): string { |
|
95 | + public static function commaList ( array $data, string $emptyText = 'nessuno' ): string { |
|
96 | 96 | if ( count( $data ) > 1 ) { |
97 | 97 | $last = array_pop( $data ); |
98 | 98 | $ret = implode( ', ', $data ) . " e $last"; |
99 | 99 | } elseif ( $data ) { |
100 | - $ret = (string)$data[0]; |
|
100 | + $ret = (string)$data[ 0 ]; |
|
101 | 101 | } else { |
102 | 102 | $ret = $emptyText; |
103 | 103 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | return $ret; |
106 | 106 | } |
107 | 107 | |
108 | - public function __toString(): string { |
|
108 | + public function __toString (): string { |
|
109 | 109 | return $this->text(); |
110 | 110 | } |
111 | 111 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Utils; |
4 | 4 | |
@@ -9,5 +9,5 @@ discard block |
||
9 | 9 | * @param string $delimiter |
10 | 10 | * @return string |
11 | 11 | */ |
12 | - public function getRegex( string $delimiter ): string; |
|
12 | + public function getRegex ( string $delimiter ): string; |
|
13 | 13 | } |