@@ -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 | |
@@ -13,12 +13,12 @@ discard block |
||
| 13 | 13 | /** @var self */ |
| 14 | 14 | private static $instance; |
| 15 | 15 | /** @var array */ |
| 16 | - private $opts = []; |
|
| 16 | + private $opts = [ ]; |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Use self::init() and self::getInstance() |
| 20 | 20 | */ |
| 21 | - private function __construct() { |
|
| 21 | + private function __construct () { |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -27,16 +27,16 @@ discard block |
||
| 27 | 27 | * @param array $defaults |
| 28 | 28 | * @throws ConfigException |
| 29 | 29 | */ |
| 30 | - public static function init( array $defaults ) { |
|
| 30 | + public static function init ( array $defaults ) { |
|
| 31 | 31 | if ( self::$instance ) { |
| 32 | 32 | throw new ConfigException( 'Config was already initialized' ); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $inst = new self; |
| 36 | - $inst->set( 'list-title', $defaults['list-title'] ); |
|
| 37 | - $inst->set( 'msg-title', $defaults['msg-title'] ); |
|
| 38 | - $inst->set( 'username', $defaults['username'] ); |
|
| 39 | - $inst->set( 'password', $defaults['password'] ); |
|
| 36 | + $inst->set( 'list-title', $defaults[ 'list-title' ] ); |
|
| 37 | + $inst->set( 'msg-title', $defaults[ 'msg-title' ] ); |
|
| 38 | + $inst->set( 'username', $defaults[ 'username' ] ); |
|
| 39 | + $inst->set( 'password', $defaults[ 'password' ] ); |
|
| 40 | 40 | self::$instance = $inst; |
| 41 | 41 | |
| 42 | 42 | // On-wiki values |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @return string |
| 57 | 57 | * @throws ConfigException |
| 58 | 58 | */ |
| 59 | - public function getWikiMessage( string $key ) : string { |
|
| 59 | + public function getWikiMessage ( string $key ) : string { |
|
| 60 | 60 | static $messages = null; |
| 61 | 61 | if ( $messages === null ) { |
| 62 | 62 | try { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | if ( !isset( $messages[ $key ] ) ) { |
| 70 | 70 | throw new ConfigException( "Message '$key' does not exist." ); |
| 71 | 71 | } |
| 72 | - return $messages[$key]; |
|
| 72 | + return $messages[ $key ]; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param string $key |
| 79 | 79 | * @param mixed $value |
| 80 | 80 | */ |
| 81 | - protected function set( string $key, $value ) { |
|
| 81 | + protected function set ( string $key, $value ) { |
|
| 82 | 82 | $this->opts[ $key ] = $value; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @return self |
| 89 | 89 | * @throws ConfigException |
| 90 | 90 | */ |
| 91 | - public static function getInstance() : self { |
|
| 91 | + public static function getInstance () : self { |
|
| 92 | 92 | if ( !self::$instance ) { |
| 93 | 93 | throw new ConfigException( 'Config not yet initialized' ); |
| 94 | 94 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @return mixed |
| 103 | 103 | * @throws ConfigException |
| 104 | 104 | */ |
| 105 | - public function get( string $opt ) { |
|
| 105 | + public function get ( string $opt ) { |
|
| 106 | 106 | if ( !isset( $this->opts[ $opt ] ) ) { |
| 107 | 107 | throw new ConfigException( "Config option '$opt' not set." ); |
| 108 | 108 | } |