@@ -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 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @param MessageProvider $mp |
| 63 | 63 | * @param PageBotList $pbl |
| 64 | 64 | */ |
| 65 | - public function __construct( |
|
| 65 | + public function __construct ( |
|
| 66 | 66 | LoggerInterface $logger, |
| 67 | 67 | WikiGroup $wikiGroup, |
| 68 | 68 | MessageProvider $mp, |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK |
| 88 | 88 | * @return TaskResult |
| 89 | 89 | */ |
| 90 | - public function run( string $mode, string $name = null ) : TaskResult { |
|
| 90 | + public function run ( string $mode, string $name = null ) : TaskResult { |
|
| 91 | 91 | if ( $mode === self::MODE_COMPLETE ) { |
| 92 | 92 | return $this->runAllTasks(); |
| 93 | 93 | } elseif ( $name === null ) { |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @return TaskResult |
| 104 | 104 | */ |
| 105 | - protected function runAllTasks() : TaskResult { |
|
| 105 | + protected function runAllTasks () : TaskResult { |
|
| 106 | 106 | $orderedList = [ |
| 107 | 107 | 'update-list', |
| 108 | 108 | 'start-new', |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @param string $name |
| 125 | 125 | * @return TaskResult |
| 126 | 126 | */ |
| 127 | - protected function runTask( string $name ) : TaskResult { |
|
| 127 | + protected function runTask ( string $name ) : TaskResult { |
|
| 128 | 128 | if ( !isset( self::TASKS_MAP[ $name ] ) ) { |
| 129 | 129 | throw new \InvalidArgumentException( "'$name' is not a valid task." ); |
| 130 | 130 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @param string $name |
| 139 | 139 | * @return TaskResult |
| 140 | 140 | */ |
| 141 | - protected function runSubtask( string $name ) : TaskResult { |
|
| 141 | + protected function runSubtask ( string $name ) : TaskResult { |
|
| 142 | 142 | if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) { |
| 143 | 143 | throw new \InvalidArgumentException( "'$name' is not a valid subtask." ); |
| 144 | 144 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param string $name |
| 154 | 154 | * @return Task |
| 155 | 155 | */ |
| 156 | - private function getTaskInstance( string $name ) : Task { |
|
| 156 | + private function getTaskInstance ( string $name ) : Task { |
|
| 157 | 157 | $class = self::TASKS_MAP[ $name ]; |
| 158 | 158 | /** @var Task $ret */ |
| 159 | 159 | $ret = new $class( |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @param string $class |
| 173 | 173 | * @return Subtask |
| 174 | 174 | */ |
| 175 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
| 175 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
| 176 | 176 | /** @var Subtask $ret */ |
| 177 | 177 | $ret = new $class( |
| 178 | 178 | $this->logger, |
@@ -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 | * @param string $domain |
| 11 | 11 | */ |
| 12 | - public function __construct( string $domain ) { |
|
| 12 | + public function __construct ( string $domain ) { |
|
| 13 | 13 | $this->domain = $domain; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @param array $params |
| 18 | 18 | * @return RequestBase |
| 19 | 19 | */ |
| 20 | - public function newFromParams( array $params ) : RequestBase { |
|
| 20 | + public function newFromParams ( array $params ) : RequestBase { |
|
| 21 | 21 | if ( extension_loaded( 'curl' ) ) { |
| 22 | 22 | $ret = new CurlRequest( $params, $this->domain ); |
| 23 | 23 | } else { |
@@ -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 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param MessageProvider $mp |
| 37 | 37 | * @param PageBotList $pbl |
| 38 | 38 | */ |
| 39 | - public function __construct( |
|
| 39 | + public function __construct ( |
|
| 40 | 40 | LoggerInterface $logger, |
| 41 | 41 | WikiGroup $wikiGroup, |
| 42 | 42 | MessageProvider $mp, |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @return LoggerInterface |
| 54 | 54 | */ |
| 55 | - protected function getLogger() : LoggerInterface { |
|
| 55 | + protected function getLogger () : LoggerInterface { |
|
| 56 | 56 | return $this->logger; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @inheritDoc |
| 61 | 61 | */ |
| 62 | - public function setLogger( LoggerInterface $logger ) : void { |
|
| 62 | + public function setLogger ( LoggerInterface $logger ) : void { |
|
| 63 | 63 | $this->logger = $logger; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -69,21 +69,21 @@ discard block |
||
| 69 | 69 | * @param string $optname |
| 70 | 70 | * @return mixed |
| 71 | 71 | */ |
| 72 | - protected function getOpt( string $optname ) { |
|
| 72 | + protected function getOpt ( string $optname ) { |
|
| 73 | 73 | return $this->getConfig()->get( $optname ); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * @return Config |
| 78 | 78 | */ |
| 79 | - protected function getConfig() : Config { |
|
| 79 | + protected function getConfig () : Config { |
|
| 80 | 80 | return $this->config; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * @param Config $cfg |
| 85 | 85 | */ |
| 86 | - protected function setConfig( Config $cfg ) : void { |
|
| 86 | + protected function setConfig ( Config $cfg ) : void { |
|
| 87 | 87 | $this->config = $cfg; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -91,35 +91,35 @@ discard block |
||
| 91 | 91 | * Shorthand |
| 92 | 92 | * @return Wiki |
| 93 | 93 | */ |
| 94 | - protected function getWiki() : Wiki { |
|
| 94 | + protected function getWiki () : Wiki { |
|
| 95 | 95 | return $this->getWikiGroup()->getMainWiki(); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * @return WikiGroup |
| 100 | 100 | */ |
| 101 | - protected function getWikiGroup() : WikiGroup { |
|
| 101 | + protected function getWikiGroup () : WikiGroup { |
|
| 102 | 102 | return $this->wikiGroup; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * @param WikiGroup $wikiGroup |
| 107 | 107 | */ |
| 108 | - protected function setWikiGroup( WikiGroup $wikiGroup ) : void { |
|
| 108 | + protected function setWikiGroup ( WikiGroup $wikiGroup ) : void { |
|
| 109 | 109 | $this->wikiGroup = $wikiGroup; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * @return MessageProvider |
| 114 | 114 | */ |
| 115 | - protected function getMessageProvider() : MessageProvider { |
|
| 115 | + protected function getMessageProvider () : MessageProvider { |
|
| 116 | 116 | return $this->messageProvider; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * @param MessageProvider $mp |
| 121 | 121 | */ |
| 122 | - protected function setMessageProvider( MessageProvider $mp ) : void { |
|
| 122 | + protected function setMessageProvider ( MessageProvider $mp ) : void { |
|
| 123 | 123 | $this->messageProvider = $mp; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -129,21 +129,21 @@ discard block |
||
| 129 | 129 | * @param string $key |
| 130 | 130 | * @return Message |
| 131 | 131 | */ |
| 132 | - protected function msg( string $key ) : Message { |
|
| 132 | + protected function msg ( string $key ) : Message { |
|
| 133 | 133 | return $this->messageProvider->getMessage( $key ); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * @return PageBotList |
| 138 | 138 | */ |
| 139 | - public function getBotList() : PageBotList { |
|
| 139 | + public function getBotList () : PageBotList { |
|
| 140 | 140 | return $this->pageBotList; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * @return RequestFactory |
| 145 | 145 | */ |
| 146 | - public function getRequestFactory() : RequestFactory { |
|
| 146 | + public function getRequestFactory () : RequestFactory { |
|
| 147 | 147 | return $this->getWiki()->getRequestFactory(); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param string $title |
| 154 | 154 | * @return Page |
| 155 | 155 | */ |
| 156 | - protected function getPage( string $title ) : Page { |
|
| 156 | + protected function getPage ( string $title ) : Page { |
|
| 157 | 157 | return new Page( $title, $this->getWiki() ); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param string $name |
| 164 | 164 | * @return User |
| 165 | 165 | */ |
| 166 | - protected function getUser( string $name ) : User { |
|
| 166 | + protected function getUser ( string $name ) : User { |
|
| 167 | 167 | $ui = $this->getBotList()->getUserInfo( $name ); |
| 168 | 168 | return new User( $ui, $this->getWiki() ); |
| 169 | 169 | } |
@@ -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 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @param string $name |
| 18 | 18 | * @param array $info |
| 19 | 19 | */ |
| 20 | - public function __construct( string $name, array $info ) { |
|
| 20 | + public function __construct ( string $name, array $info ) { |
|
| 21 | 21 | $this->name = $name; |
| 22 | 22 | $this->info = $info; |
| 23 | 23 | } |
@@ -25,35 +25,35 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | - public function getName() : string { |
|
| 28 | + public function getName () : string { |
|
| 29 | 29 | return $this->name; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * @return array |
| 34 | 34 | */ |
| 35 | - public function getInfo() : array { |
|
| 35 | + public function getInfo () : array { |
|
| 36 | 36 | return $this->info; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * @return array |
| 41 | 41 | */ |
| 42 | - public function extractGroups() : array { |
|
| 42 | + public function extractGroups () : array { |
|
| 43 | 43 | return array_keys( $this->extractGroupsWithDates() ); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * @return array |
| 48 | 48 | */ |
| 49 | - public function extractGroupsWithDates() : array { |
|
| 49 | + public function extractGroupsWithDates () : array { |
|
| 50 | 50 | return array_intersect_key( $this->getInfo(), array_fill_keys( self::GROUP_KEYS, 1 ) ); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * @return array |
| 55 | 55 | */ |
| 56 | - public function getAliases() : array { |
|
| 57 | - return $this->getInfo()['aliases'] ?? []; |
|
| 56 | + public function getAliases () : array { |
|
| 57 | + return $this->getInfo()[ 'aliases' ] ?? [ ]; |
|
| 58 | 58 | } |
| 59 | 59 | } |
@@ -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\Page; |
| 4 | 4 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param string $title |
| 22 | 22 | * @param Wiki $wiki For the site where the page lives |
| 23 | 23 | */ |
| 24 | - public function __construct( string $title, Wiki $wiki ) { |
|
| 24 | + public function __construct ( string $title, Wiki $wiki ) { |
|
| 25 | 25 | $this->wiki = $wiki; |
| 26 | 26 | $this->title = $title; |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | - public function getTitle() : string { |
|
| 32 | + public function getTitle () : string { |
|
| 33 | 33 | return $this->title; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param int|null $section A section number to retrieve the content of that section |
| 40 | 40 | * @return string |
| 41 | 41 | */ |
| 42 | - public function getContent( int $section = null ) : string { |
|
| 42 | + public function getContent ( int $section = null ) : string { |
|
| 43 | 43 | if ( $this->content === null ) { |
| 44 | 44 | $this->content = $this->wiki->getPageContent( $this->title, $section ); |
| 45 | 45 | } |
@@ -52,18 +52,18 @@ discard block |
||
| 52 | 52 | * @param array $params |
| 53 | 53 | * @throws \LogicException |
| 54 | 54 | */ |
| 55 | - public function edit( array $params ) : void { |
|
| 55 | + public function edit ( array $params ) : void { |
|
| 56 | 56 | $params = [ |
| 57 | 57 | 'title' => $this->getTitle() |
| 58 | 58 | ] + $params; |
| 59 | 59 | |
| 60 | 60 | $this->wiki->editPage( $params ); |
| 61 | - if ( isset( $params['text'] ) ) { |
|
| 62 | - $this->content = $params['text']; |
|
| 63 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
| 64 | - $this->content .= $params['appendtext']; |
|
| 65 | - } elseif ( isset( $params['prependtext'] ) ) { |
|
| 66 | - $this->content = $params['prependtext'] . $this->content; |
|
| 61 | + if ( isset( $params[ 'text' ] ) ) { |
|
| 62 | + $this->content = $params[ 'text' ]; |
|
| 63 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
| 64 | + $this->content .= $params[ 'appendtext' ]; |
|
| 65 | + } elseif ( isset( $params[ 'prependtext' ] ) ) { |
|
| 66 | + $this->content = $params[ 'prependtext' ] . $this->content; |
|
| 67 | 67 | } else { |
| 68 | 68 | throw new \LogicException( |
| 69 | 69 | 'Unrecognized text param for edit. Params: ' . var_export( $params, true ) |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return bool |
| 78 | 78 | */ |
| 79 | - public function exists() : bool { |
|
| 79 | + public function exists () : bool { |
|
| 80 | 80 | $res = $this->wiki->getRequestFactory()->newFromParams( [ |
| 81 | 81 | 'action' => 'query', |
| 82 | 82 | 'titles' => $this->getTitle() |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $regex |
| 92 | 92 | * @return bool |
| 93 | 93 | */ |
| 94 | - public function matches( string $regex ) : bool { |
|
| 94 | + public function matches ( string $regex ) : bool { |
|
| 95 | 95 | return (bool)preg_match( $regex, $this->getContent() ); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | * @return string[] |
| 104 | 104 | * @throws MissingMatchException |
| 105 | 105 | */ |
| 106 | - public function getMatch( string $regex ) : array { |
|
| 107 | - $ret = []; |
|
| 106 | + public function getMatch ( string $regex ) : array { |
|
| 107 | + $ret = [ ]; |
|
| 108 | 108 | if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) { |
| 109 | 109 | throw new MissingMatchException( "The content of $this does not match the given regex $regex" ); |
| 110 | 110 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @inheritDoc |
| 118 | 118 | */ |
| 119 | - public function getRegex( string $delimiter = '/' ) : string { |
|
| 119 | + public function getRegex ( string $delimiter = '/' ) : string { |
|
| 120 | 120 | return str_replace( ' ', '[ _]', preg_quote( $this->title, $delimiter ) ); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return string |
| 127 | 127 | */ |
| 128 | - public function __toString() { |
|
| 128 | + public function __toString () { |
|
| 129 | 129 | return $this->getTitle(); |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -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\Page; |
| 4 | 4 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @param string $listTitle |
| 20 | 20 | * @param Wiki $wiki |
| 21 | 21 | */ |
| 22 | - public function __construct( string $listTitle, Wiki $wiki ) { |
|
| 22 | + public function __construct ( string $listTitle, Wiki $wiki ) { |
|
| 23 | 23 | parent::__construct( $listTitle, $wiki ); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param string $listTitle |
| 31 | 31 | * @return self |
| 32 | 32 | */ |
| 33 | - public static function get( Wiki $wiki, string $listTitle ) : self { |
|
| 33 | + public static function get ( Wiki $wiki, string $listTitle ) : self { |
|
| 34 | 34 | static $instance = null; |
| 35 | 35 | if ( $instance === null ) { |
| 36 | 36 | $instance = new self( $listTitle, $wiki ); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param UserInfo $ui |
| 43 | 43 | * @return int|null |
| 44 | 44 | */ |
| 45 | - public function getOverrideTimestamp( UserInfo $ui ) : ?int { |
|
| 45 | + public function getOverrideTimestamp ( UserInfo $ui ) : ?int { |
|
| 46 | 46 | $info = $ui->getInfo(); |
| 47 | 47 | if ( !array_intersect_key( $info, [ 'override-perm' => true, 'override' => true ] ) ) { |
| 48 | 48 | return null; |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | // A one-time override takes precedence |
| 52 | 52 | if ( array_key_exists( 'override', $info ) ) { |
| 53 | - $date = $info['override']; |
|
| 53 | + $date = $info[ 'override' ]; |
|
| 54 | 54 | } else { |
| 55 | - $date = $info['override-prem'] . '/' . date( 'Y' ); |
|
| 55 | + $date = $info[ 'override-prem' ] . '/' . date( 'Y' ); |
|
| 56 | 56 | } |
| 57 | 57 | return \DateTime::createFromFormat( 'd/m/Y', $date )->getTimestamp(); |
| 58 | 58 | } |
@@ -63,17 +63,17 @@ discard block |
||
| 63 | 63 | * @param string $user |
| 64 | 64 | * @return int |
| 65 | 65 | */ |
| 66 | - public function getNextTimestamp( string $user ) : int { |
|
| 66 | + public function getNextTimestamp ( string $user ) : int { |
|
| 67 | 67 | $userInfo = $this->getUserInfo( $user )->getInfo(); |
| 68 | - if ( isset( $userInfo['override-perm'] ) ) { |
|
| 68 | + if ( isset( $userInfo[ 'override-perm' ] ) ) { |
|
| 69 | 69 | $date = \DateTime::createFromFormat( |
| 70 | 70 | 'd/m/Y', |
| 71 | - $userInfo['override-perm'] . '/' . date( 'Y' ) |
|
| 71 | + $userInfo[ 'override-perm' ] . '/' . date( 'Y' ) |
|
| 72 | 72 | ); |
| 73 | 73 | } else { |
| 74 | 74 | $date = null; |
| 75 | - if ( isset( $userInfo['override'] ) ) { |
|
| 76 | - $date = \DateTime::createFromFormat( 'd/m/Y', $userInfo['override'] ); |
|
| 75 | + if ( isset( $userInfo[ 'override' ] ) ) { |
|
| 76 | + $date = \DateTime::createFromFormat( 'd/m/Y', $userInfo[ 'override' ] ); |
|
| 77 | 77 | } |
| 78 | 78 | if ( !$date || $date <= new \DateTime ) { |
| 79 | 79 | $ts = self::getValidFlagTimestamp( $userInfo ); |
@@ -92,17 +92,15 @@ discard block |
||
| 92 | 92 | * @param array $groups |
| 93 | 93 | * @return int |
| 94 | 94 | */ |
| 95 | - public static function getValidFlagTimestamp( array $groups ): int { |
|
| 96 | - $checkuser = isset( $groups['checkuser'] ) ? |
|
| 97 | - \DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() : |
|
| 98 | - 0; |
|
| 99 | - $bureaucrat = isset( $groups['bureaucrat'] ) ? |
|
| 100 | - \DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() : |
|
| 101 | - 0; |
|
| 95 | + public static function getValidFlagTimestamp ( array $groups ): int { |
|
| 96 | + $checkuser = isset( $groups[ 'checkuser' ] ) ? |
|
| 97 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0; |
|
| 98 | + $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
|
| 99 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0; |
|
| 102 | 100 | |
| 103 | 101 | $timestamp = max( $bureaucrat, $checkuser ); |
| 104 | 102 | if ( $timestamp === 0 ) { |
| 105 | - $timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp(); |
|
| 103 | + $timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp(); |
|
| 106 | 104 | } |
| 107 | 105 | return $timestamp; |
| 108 | 106 | } |
@@ -111,14 +109,14 @@ discard block |
||
| 111 | 109 | * @param array $groups |
| 112 | 110 | * @return bool |
| 113 | 111 | */ |
| 114 | - public static function isOverrideExpired( array $groups ) : bool { |
|
| 115 | - if ( !isset( $groups['override'] ) ) { |
|
| 112 | + public static function isOverrideExpired ( array $groups ) : bool { |
|
| 113 | + if ( !isset( $groups[ 'override' ] ) ) { |
|
| 116 | 114 | return false; |
| 117 | 115 | } |
| 118 | 116 | |
| 119 | 117 | $flagTS = self::getValidFlagTimestamp( $groups ); |
| 120 | 118 | $usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) ); |
| 121 | - $overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp(); |
|
| 119 | + $overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp(); |
|
| 122 | 120 | $delay = 60 * 60 * 24 * 3; |
| 123 | 121 | |
| 124 | 122 | return time() > $usualTS + $delay && time() > $overrideTS + $delay; |
@@ -129,9 +127,9 @@ discard block |
||
| 129 | 127 | * |
| 130 | 128 | * @return UserInfo[] |
| 131 | 129 | */ |
| 132 | - public function getAdminsList() : array { |
|
| 130 | + public function getAdminsList () : array { |
|
| 133 | 131 | if ( $this->adminsList === null ) { |
| 134 | - $this->adminsList = []; |
|
| 132 | + $this->adminsList = [ ]; |
|
| 135 | 133 | foreach ( $this->getDecodedContent() as $user => $info ) { |
| 136 | 134 | $this->adminsList[ $user ] = new UserInfo( $user, $info ); |
| 137 | 135 | } |
@@ -143,8 +141,8 @@ discard block |
||
| 143 | 141 | * @param string $user |
| 144 | 142 | * @return UserInfo |
| 145 | 143 | */ |
| 146 | - public function getUserInfo( string $user ) : UserInfo { |
|
| 147 | - return $this->getAdminsList()[$user]; |
|
| 144 | + public function getUserInfo ( string $user ) : UserInfo { |
|
| 145 | + return $this->getAdminsList()[ $user ]; |
|
| 148 | 146 | } |
| 149 | 147 | |
| 150 | 148 | /** |
@@ -152,7 +150,7 @@ discard block |
||
| 152 | 150 | * |
| 153 | 151 | * @return array[] |
| 154 | 152 | */ |
| 155 | - public function getDecodedContent() : array { |
|
| 153 | + public function getDecodedContent () : array { |
|
| 156 | 154 | return json_decode( $this->getContent(), true ); |
| 157 | 155 | } |
| 158 | 156 | } |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param UserInfo $ui |
| 22 | 22 | * @param Wiki $wiki |
| 23 | 23 | */ |
| 24 | - public function __construct( UserInfo $ui, Wiki $wiki ) { |
|
| 24 | + public function __construct ( UserInfo $ui, Wiki $wiki ) { |
|
| 25 | 25 | $this->wiki = $wiki; |
| 26 | 26 | $this->name = $ui->getName(); |
| 27 | 27 | $this->ui = $ui; |
@@ -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 $this->ui->extractGroups(); |
| 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 $this->ui->extractGroupsWithDates(); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @param string $groupName |
| 59 | 59 | * @return bool |
| 60 | 60 | */ |
| 61 | - public function inGroup( string $groupName ) : bool { |
|
| 61 | + public function inGroup ( string $groupName ) : bool { |
|
| 62 | 62 | return in_array( $groupName, $this->getGroups(), true ); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @inheritDoc |
| 69 | 69 | */ |
| 70 | - public function getRegex( string $delimiter = '/' ) : string { |
|
| 70 | + public function getRegex ( string $delimiter = '/' ) : string { |
|
| 71 | 71 | $bits = $this->getAliases(); |
| 72 | - $bits[] = $this->name; |
|
| 72 | + $bits[ ] = $this->name; |
|
| 73 | 73 | $regexify = static function ( $el ) use ( $delimiter ) { |
| 74 | 74 | return str_replace( ' ', '[ _]', preg_quote( $el, $delimiter ) ); |
| 75 | 75 | }; |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | * |
| 82 | 82 | * @return string[] |
| 83 | 83 | */ |
| 84 | - public function getAliases() : array { |
|
| 84 | + public function getAliases () : array { |
|
| 85 | 85 | return $this->ui->getAliases(); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * @return Page |
| 90 | 90 | */ |
| 91 | - public function getTalkPage() : Page { |
|
| 91 | + public function getTalkPage () : Page { |
|
| 92 | 92 | return new Page( "User talk:{$this->name}", $this->wiki ); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * Get the default base page, e.g. WP:A/Riconferma annuale/XXX |
| 97 | 97 | * @return Page |
| 98 | 98 | */ |
| 99 | - public function getBasePage() : Page { |
|
| 99 | + public function getBasePage () : Page { |
|
| 100 | 100 | $prefix = Config::getInstance()->get( 'main-page-title' ); |
| 101 | 101 | return new Page( "$prefix/$this", $this->wiki ); |
| 102 | 102 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @throws MissingPageException |
| 109 | 109 | * @return Page |
| 110 | 110 | */ |
| 111 | - public function getExistingBasePage() : Page { |
|
| 111 | + public function getExistingBasePage () : Page { |
|
| 112 | 112 | $basePage = $this->getBasePage(); |
| 113 | 113 | if ( !$basePage->exists() ) { |
| 114 | 114 | $basePage = null; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | /** |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | - public function __toString() { |
|
| 135 | + public function __toString () { |
|
| 136 | 136 | return $this->name; |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -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 | } |
@@ -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 | |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | * @param IRegexAble ...$elements |
| 11 | 11 | * @return string |
| 12 | 12 | */ |
| 13 | - public static function regexFromArray( |
|
| 13 | + public static function regexFromArray ( |
|
| 14 | 14 | string $delimiter = '/', |
| 15 | 15 | IRegexAble ...$elements |
| 16 | 16 | ) : string { |
| 17 | - $bits = []; |
|
| 17 | + $bits = [ ]; |
|
| 18 | 18 | foreach ( $elements as $el ) { |
| 19 | - $bits[] = $el->getRegex( $delimiter ); |
|
| 19 | + $bits[ ] = $el->getRegex( $delimiter ); |
|
| 20 | 20 | } |
| 21 | 21 | return '(?:' . implode( '|', $bits ) . ')'; |
| 22 | 22 | } |