@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Wiki; |
4 | 4 | |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @param string $delimiter |
13 | 13 | * @return string |
14 | 14 | */ |
15 | - abstract public function getRegex( string $delimiter = '/' ) : string; |
|
15 | + abstract public function getRegex ( string $delimiter = '/' ) : string; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Get a regex matching any element in the given array |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * @return string |
23 | 23 | * @todo Is this the right place? |
24 | 24 | */ |
25 | - public static function regexFromArray( array $elements, string $delimiter = '/' ) : string { |
|
26 | - $bits = []; |
|
25 | + public static function regexFromArray ( array $elements, string $delimiter = '/' ) : string { |
|
26 | + $bits = [ ]; |
|
27 | 27 | foreach ( $elements as $el ) { |
28 | - $bits[] = $el->getRegex( $delimiter ); |
|
28 | + $bits[ ] = $el->getRegex( $delimiter ); |
|
29 | 29 | } |
30 | 30 | return '(?:' . implode( '|', $bits ) . ')'; |
31 | 31 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Wiki; |
4 | 4 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @param string $name |
23 | 23 | * @param Wiki $wiki |
24 | 24 | */ |
25 | - public function __construct( string $name, Wiki $wiki ) { |
|
25 | + public function __construct ( string $name, Wiki $wiki ) { |
|
26 | 26 | $this->wiki = $wiki; |
27 | 27 | $this->name = $name; |
28 | 28 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @return string |
32 | 32 | */ |
33 | - public function getName() : string { |
|
33 | + public function getName () : string { |
|
34 | 34 | return $this->name; |
35 | 35 | } |
36 | 36 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return string[] |
41 | 41 | */ |
42 | - public function getGroups() : array { |
|
42 | + public function getGroups () : array { |
|
43 | 43 | return array_diff( array_keys( $this->getUserInfo() ), PageBotList::NON_GROUP_KEYS ); |
44 | 44 | } |
45 | 45 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return string[] [ group => date ] |
50 | 50 | */ |
51 | - public function getGroupsWithDates() : array { |
|
51 | + public function getGroupsWithDates () : array { |
|
52 | 52 | return array_intersect_key( $this->getUserInfo(), array_fill_keys( $this->getGroups(), 1 ) ); |
53 | 53 | } |
54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return string[] |
59 | 59 | */ |
60 | - public function getUserInfo() : array { |
|
60 | + public function getUserInfo () : array { |
|
61 | 61 | if ( $this->info === null ) { |
62 | 62 | $usersList = PageBotList::get( $this->wiki )->getAdminsList(); |
63 | 63 | $this->info = $usersList[ $this->name ]->getUserInfo(); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * @param array|null $info |
70 | 70 | */ |
71 | - public function setInfo( ?array $info ) : void { |
|
71 | + public function setInfo ( ?array $info ) : void { |
|
72 | 72 | $this->info = $info; |
73 | 73 | } |
74 | 74 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param string $groupName |
79 | 79 | * @return bool |
80 | 80 | */ |
81 | - public function inGroup( string $groupName ) : bool { |
|
81 | + public function inGroup ( string $groupName ) : bool { |
|
82 | 82 | return in_array( $groupName, $this->getGroups(), true ); |
83 | 83 | } |
84 | 84 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @inheritDoc |
89 | 89 | */ |
90 | - public function getRegex( string $delimiter = '/' ) : string { |
|
90 | + public function getRegex ( string $delimiter = '/' ) : string { |
|
91 | 91 | $bits = $this->getAliases(); |
92 | - $bits[] = $this->name; |
|
92 | + $bits[ ] = $this->name; |
|
93 | 93 | $regexify = static function ( $el ) use ( $delimiter ) { |
94 | 94 | return str_replace( ' ', '[ _]', preg_quote( $el, $delimiter ) ); |
95 | 95 | }; |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string[] |
103 | 103 | */ |
104 | - public function getAliases() : array { |
|
105 | - return $this->getUserInfo()['aliases'] ?? []; |
|
104 | + public function getAliases () : array { |
|
105 | + return $this->getUserInfo()[ 'aliases' ] ?? [ ]; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * @return Page |
110 | 110 | */ |
111 | - public function getTalkPage() : Page { |
|
111 | + public function getTalkPage () : Page { |
|
112 | 112 | return new Page( "User talk:{$this->name}", $this->wiki ); |
113 | 113 | } |
114 | 114 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * Get the default base page, e.g. WP:A/Riconferma annuale/XXX |
117 | 117 | * @return Page |
118 | 118 | */ |
119 | - public function getBasePage() : Page { |
|
119 | + public function getBasePage () : Page { |
|
120 | 120 | $prefix = Config::getInstance()->get( 'main-page-title' ); |
121 | 121 | return new Page( "$prefix/$this", $this->wiki ); |
122 | 122 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @throws MissingPageException |
129 | 129 | * @return Page |
130 | 130 | */ |
131 | - public function getExistingBasePage() : Page { |
|
131 | + public function getExistingBasePage () : Page { |
|
132 | 132 | $basePage = $this->getBasePage(); |
133 | 133 | if ( !$basePage->exists() ) { |
134 | 134 | $basePage = null; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | /** |
153 | 153 | * @return string |
154 | 154 | */ |
155 | - public function __toString() { |
|
155 | + public function __toString () { |
|
156 | 156 | return $this->name; |
157 | 157 | } |
158 | 158 | } |