@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | abstract class TaskBase extends ContextSource { |
| 15 | 15 | /** @var string[] */ |
| 16 | - protected $errors = []; |
|
| 16 | + protected $errors = [ ]; |
|
| 17 | 17 | /** @var TaskDataProvider */ |
| 18 | 18 | protected $dataProvider; |
| 19 | 19 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @param Controller $controller |
| 25 | 25 | * @param TaskDataProvider $dataProvider |
| 26 | 26 | */ |
| 27 | - final public function __construct( |
|
| 27 | + final public function __construct ( |
|
| 28 | 28 | Logger $logger, |
| 29 | 29 | Controller $controller, |
| 30 | 30 | TaskDataProvider $dataProvider |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $this->dataProvider = $dataProvider; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function __destruct() { |
|
| 38 | + public function __destruct () { |
|
| 39 | 39 | restore_error_handler(); |
| 40 | 40 | restore_exception_handler(); |
| 41 | 41 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return TaskResult |
| 47 | 47 | */ |
| 48 | - final public function run() : TaskResult { |
|
| 48 | + final public function run () : TaskResult { |
|
| 49 | 49 | $class = ( new \ReflectionClass( $this ) )->getShortName(); |
| 50 | 50 | $opName = $this->getOperationName(); |
| 51 | 51 | $this->getLogger()->info( "Starting $opName $class" ); |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return int One of the STATUS_* constants |
| 78 | 78 | */ |
| 79 | - abstract protected function runInternal() : int; |
|
| 79 | + abstract protected function runInternal () : int; |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * How this operation should be called in logs |
| 83 | 83 | * |
| 84 | 84 | * @return string |
| 85 | 85 | */ |
| 86 | - abstract public function getOperationName() : string; |
|
| 86 | + abstract public function getOperationName () : string; |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Exception handler. |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param \Throwable $ex |
| 92 | 92 | * @protected |
| 93 | 93 | */ |
| 94 | - public function handleException( \Throwable $ex ) { |
|
| 94 | + public function handleException ( \Throwable $ex ) { |
|
| 95 | 95 | $this->getLogger()->error( |
| 96 | 96 | ( new \ReflectionClass( $ex ) )->getShortName() . ': ' . |
| 97 | 97 | $ex->getMessage() . "\nin " . $ex->getFile() . ' line ' . |
@@ -109,14 +109,14 @@ discard block |
||
| 109 | 109 | * @throws \ErrorException |
| 110 | 110 | * @protected |
| 111 | 111 | */ |
| 112 | - public function handleError( $errno, $errstr, $errfile, $errline ) { |
|
| 112 | + public function handleError ( $errno, $errstr, $errfile, $errline ) { |
|
| 113 | 113 | throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline ); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * @return TaskDataProvider |
| 118 | 118 | */ |
| 119 | - protected function getDataProvider() : TaskDataProvider { |
|
| 119 | + protected function getDataProvider () : TaskDataProvider { |
|
| 120 | 120 | return $this->dataProvider; |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -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 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @param Logger $logger |
| 25 | 25 | * @param Controller $controller |
| 26 | 26 | */ |
| 27 | - public function __construct( Logger $logger, Controller $controller ) { |
|
| 27 | + public function __construct ( Logger $logger, Controller $controller ) { |
|
| 28 | 28 | $this->setLogger( $logger ); |
| 29 | 29 | $this->setConfig( Config::getInstance() ); |
| 30 | 30 | $this->setController( $controller ); |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @return LoggerInterface |
| 35 | 35 | */ |
| 36 | - protected function getLogger() : LoggerInterface { |
|
| 36 | + protected function getLogger () : LoggerInterface { |
|
| 37 | 37 | return $this->logger; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * @inheritDoc |
| 42 | 42 | */ |
| 43 | - public function setLogger( LoggerInterface $logger ) { |
|
| 43 | + public function setLogger ( LoggerInterface $logger ) { |
|
| 44 | 44 | $this->logger = $logger; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -50,35 +50,35 @@ discard block |
||
| 50 | 50 | * @param string $optname |
| 51 | 51 | * @return mixed |
| 52 | 52 | */ |
| 53 | - protected function getOpt( string $optname ) { |
|
| 53 | + protected function getOpt ( string $optname ) { |
|
| 54 | 54 | return $this->getConfig()->get( $optname ); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * @return Config |
| 59 | 59 | */ |
| 60 | - protected function getConfig() : Config { |
|
| 60 | + protected function getConfig () : Config { |
|
| 61 | 61 | return $this->config; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * @param Config $cfg |
| 66 | 66 | */ |
| 67 | - protected function setConfig( Config $cfg ) { |
|
| 67 | + protected function setConfig ( Config $cfg ) { |
|
| 68 | 68 | $this->config = $cfg; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * @return Controller |
| 73 | 73 | */ |
| 74 | - protected function getController() : Controller { |
|
| 74 | + protected function getController () : Controller { |
|
| 75 | 75 | return $this->controller; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * @param Controller $controller |
| 80 | 80 | */ |
| 81 | - protected function setController( Controller $controller ) { |
|
| 81 | + protected function setController ( Controller $controller ) { |
|
| 82 | 82 | $this->controller = $controller; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param string $key |
| 89 | 89 | * @return Message |
| 90 | 90 | */ |
| 91 | - protected function msg( string $key ) : Message { |
|
| 91 | + protected function msg ( string $key ) : Message { |
|
| 92 | 92 | return new Message( $key ); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @param string $title |
| 99 | 99 | * @return Page |
| 100 | 100 | */ |
| 101 | - protected function getPage( string $title ) : Page { |
|
| 101 | + protected function getPage ( string $title ) : Page { |
|
| 102 | 102 | return new Page( $title, $this->getController() ); |
| 103 | 103 | } |
| 104 | 104 | } |