@@ -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 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @inheritDoc |
| 26 | 26 | * @suppress PhanUnusedPublicMethodParameter |
| 27 | 27 | */ |
| 28 | - public function log( $level, $message, array $context = [] ) : void { |
|
| 28 | + public function log ( $level, $message, array $context = [ ] ) : void { |
|
| 29 | 29 | if ( $this->levelToInt( $level ) >= $this->minLevel ) { |
| 30 | 30 | echo $this->getFormattedMessage( $level, $message ) . "\n"; |
| 31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @inheritDoc |
| 36 | 36 | */ |
| 37 | - public function flush() : void { |
|
| 37 | + public function flush () : void { |
|
| 38 | 38 | // Everything else is printed immediately |
| 39 | 39 | echo "\n" . str_repeat( '-', 80 ) . "\n\n"; |
| 40 | 40 | } |
@@ -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 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @inheritDoc |
| 23 | 23 | * @suppress PhanUnusedPublicMethodParameter |
| 24 | 24 | */ |
| 25 | - public function log( $level, $message, array $context = [] ) :void { |
|
| 25 | + public function log ( $level, $message, array $context = [ ] ) :void { |
|
| 26 | 26 | foreach ( $this->loggers as $logger ) { |
| 27 | 27 | $logger->log( $level, $message ); |
| 28 | 28 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * @inheritDoc |
| 33 | 33 | */ |
| 34 | - public function flush() : void { |
|
| 34 | + public function flush () : void { |
|
| 35 | 35 | foreach ( $this->loggers as $logger ) { |
| 36 | 36 | $logger->flush(); |
| 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 | |
@@ -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 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Request; |
| 4 | 4 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | /** |
| 10 | 10 | * @inheritDoc |
| 11 | 11 | */ |
| 12 | - protected function reallyMakeRequest( string $params ) : string { |
|
| 12 | + protected function reallyMakeRequest ( string $params ) : string { |
|
| 13 | 13 | $context = [ |
| 14 | 14 | 'http' => [ |
| 15 | 15 | 'method' => $this->method, |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | ]; |
| 19 | 19 | $url = $this->url; |
| 20 | 20 | if ( $this->method === self::METHOD_POST ) { |
| 21 | - $context['http']['content'] = $params; |
|
| 21 | + $context[ 'http' ][ 'content' ] = $params; |
|
| 22 | 22 | } else { |
| 23 | 23 | $url = "$url?$params"; |
| 24 | 24 | } |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | foreach ( $http_response_header as $header ) { |
| 29 | 29 | $bits = explode( ':', $header, 2 ); |
| 30 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
| 31 | - $this->newCookies[] = $bits[1]; |
|
| 30 | + if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) { |
|
| 31 | + $this->newCookies[ ] = $bits[ 1 ]; |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
@@ -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 | |
@@ -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 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param array $args |
| 32 | 32 | * @return self |
| 33 | 33 | */ |
| 34 | - public function params( array $args ) : self { |
|
| 34 | + public function params ( array $args ) : self { |
|
| 35 | 35 | $this->value = strtr( $this->value, $args ); |
| 36 | 36 | return $this; |
| 37 | 37 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * @return string |
| 41 | 41 | */ |
| 42 | - public function text() : string { |
|
| 42 | + public function text () : string { |
|
| 43 | 43 | $this->parsePlurals(); |
| 44 | 44 | return $this->value; |
| 45 | 45 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * Replace {{$plur|<amount>|sing|plur}} |
| 49 | 49 | */ |
| 50 | - protected function parsePlurals() : void { |
|
| 50 | + protected function parsePlurals () : void { |
|
| 51 | 51 | $reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!'; |
| 52 | 52 | |
| 53 | 53 | if ( preg_match( $reg, $this->value ) === 0 ) { |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $this->value = preg_replace_callback( |
| 57 | 57 | $reg, |
| 58 | 58 | static function ( $matches ) { |
| 59 | - return (int)$matches['amount'] > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] ); |
|
| 59 | + return (int)$matches[ 'amount' ] > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] ); |
|
| 60 | 60 | }, |
| 61 | 61 | $this->value |
| 62 | 62 | ); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param string $timeString Full format, e.g. "15 aprile 2019 18:27" |
| 69 | 69 | * @return int |
| 70 | 70 | */ |
| 71 | - public static function getTimestampFromLocalTime( string $timeString ) : int { |
|
| 71 | + public static function getTimestampFromLocalTime ( string $timeString ) : int { |
|
| 72 | 72 | $englishTime = str_ireplace( |
| 73 | 73 | array_values( self::MONTHS ), |
| 74 | 74 | array_keys( self::MONTHS ), |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | * @param string $emptyText |
| 87 | 87 | * @return string |
| 88 | 88 | */ |
| 89 | - public static function commaList( array $data, string $emptyText = 'nessuno' ) : string { |
|
| 89 | + public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string { |
|
| 90 | 90 | if ( count( $data ) > 1 ) { |
| 91 | 91 | $last = array_pop( $data ); |
| 92 | 92 | $ret = implode( ', ', $data ) . " e $last"; |
| 93 | 93 | } elseif ( $data ) { |
| 94 | - $ret = (string)$data[0]; |
|
| 94 | + $ret = (string)$data[ 0 ]; |
|
| 95 | 95 | } else { |
| 96 | 96 | $ret = $emptyText; |
| 97 | 97 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | return $ret; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public function __toString() { |
|
| 102 | + public function __toString () { |
|
| 103 | 103 | return $this->text(); |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task; |
| 4 | 4 | |
@@ -14,13 +14,13 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @return string[] |
| 16 | 16 | */ |
| 17 | - abstract protected function getSubtasksMap() : array; |
|
| 17 | + abstract protected function getSubtasksMap () : array; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @param string $subtask Defined in self::SUBTASKS_MAP |
| 21 | 21 | * @return TaskResult |
| 22 | 22 | */ |
| 23 | - protected function runSubtask( string $subtask ) : TaskResult { |
|
| 23 | + protected function runSubtask ( string $subtask ) : TaskResult { |
|
| 24 | 24 | $map = $this->getSubtasksMap(); |
| 25 | 25 | if ( !isset( $map[ $subtask ] ) ) { |
| 26 | 26 | throw new \InvalidArgumentException( "'$subtask' is not a valid task." ); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @inheritDoc |
| 35 | 35 | */ |
| 36 | - final public function getOperationName(): string { |
|
| 36 | + final public function getOperationName (): string { |
|
| 37 | 37 | return 'task'; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param string $class |
| 44 | 44 | * @return Subtask |
| 45 | 45 | */ |
| 46 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
| 46 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
| 47 | 47 | /** @var Subtask $ret */ |
| 48 | 48 | $ret = new $class( |
| 49 | 49 | $this->getLogger(), |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |