@@ -31,7 +31,7 @@ class Aggregator extends BaseModule
3131 protected $ sourcePool = null ;
3232
3333 /**
34- * Set up the module.
34+ * @return void
3535 */
3636 public function setup ()
3737 {
@@ -41,19 +41,13 @@ public function setup()
4141 $ this ->getEventEmitter ()->on ('irc.command.lssources ' , [$ this , 'lsSourcesCommand ' ]);
4242 $ this ->getEventEmitter ()->on ('irc.command ' , [$ this , 'keywordListener ' ]);
4343
44- include (__DIR__ . '/IAggregatorSource.php ' );
45- include (__DIR__ . '/SourcePool.php ' );
46- include (__DIR__ . '/SearchResult.php ' );
47-
48- include (__DIR__ . '/Sources/Wikipedia.php ' );
49- include (__DIR__ . '/Sources/ArchWiki.php ' );
50- include (__DIR__ . '/Sources/AUR.php ' );
51- include (__DIR__ . '/Sources/ArchPkg.php ' );
52-
5344 $ sourcePool = new SourcePool ($ this );
5445 $ this ->setSourcePool ($ sourcePool );
5546 }
5647
48+ /**
49+ * @return void
50+ */
5751 public function initSourcePool ()
5852 {
5953 $ sourcePool = $ this ->getSourcePool ();
@@ -78,7 +72,6 @@ public function getSourcePool()
7872 }
7973
8074 /**
81- * The lssources command
8275 * @param IrcDataObject $data The data received.
8376 */
8477 public function lsSourcesCommand ($ command , $ params , IrcDataObject $ data )
@@ -91,6 +84,12 @@ public function lsSourcesCommand($command, $params, IrcDataObject $data)
9184 $ this ->replyToChannel ($ originChannel , 'Available sources: ' . implode (', ' , $ keys ));
9285 }
9386
87+ /**
88+ * @param string $source
89+ * @param string $search
90+ * @param string $channel
91+ * @param string $user
92+ */
9493 protected function handleResult ($ source , $ search , $ channel , $ user = '' )
9594 {
9695 $ sourcePool = $ this ->getSourcePool ();
@@ -106,7 +105,7 @@ protected function handleResult($source, $search, $channel, $user = '')
106105
107106 if (!$ results )
108107 {
109- $ this ->replyToChannel ($ channel , 'I had no search results for that query. ' );
108+ $ this ->replyToChannel ($ channel , 'I had no results for that query. ' );
110109 return ;
111110 }
112111 $ result = $ this ->getBestResult ($ search , $ results );
@@ -130,11 +129,17 @@ public function findCommand($command, $params, IrcDataObject $data)
130129
131130 if (!$ paramData )
132131 {
133- $ this ->replyToChannel ($ originChannel , 'Invalid parameters. Usage: find [source] [search terms] (@ [user]) ' );
132+ $ this ->replyToChannel ($ originChannel ,
133+ 'Invalid parameters. Usage: find [source] [search terms] (@ [user]) ' );
134134 return ;
135135 }
136136
137- $ this ->handleResult ($ paramData ['source ' ], $ paramData ['search ' ], $ originChannel , $ paramData ['user ' ]);
137+ $ this ->handleResult (
138+ $ paramData ['source ' ],
139+ $ paramData ['search ' ],
140+ $ originChannel ,
141+ $ paramData ['user ' ]
142+ );
138143 }
139144
140145 public function keywordListener ($ command , $ params , IrcDataObject $ data )
@@ -149,11 +154,17 @@ public function keywordListener($command, $params, IrcDataObject $data)
149154
150155 if (empty ($ params ) || empty ($ paramData ))
151156 {
152- $ this ->replyToChannel ($ originChannel , 'You need to specify a search term. Usage: ' . $ command . ' [search term] (@ [user]) ' );
157+ $ this ->replyToChannel ($ originChannel ,
158+ 'Invalid parameters. Usage: ' . $ command . ' [search term] (@ [user]) ' );
153159 return ;
154160 }
155161
156- $ this ->handleResult ($ command , $ paramData ['search ' ], $ originChannel , $ paramData ['user ' ]);
162+ $ this ->handleResult (
163+ $ command ,
164+ $ paramData ['search ' ],
165+ $ originChannel ,
166+ $ paramData ['user ' ]
167+ );
157168 }
158169
159170 public function getBestResult ($ comparedTo , $ results )
@@ -173,7 +184,6 @@ public function getBestResult($comparedTo, $results)
173184 if ($ lev == 0 )
174185 {
175186 $ bestResult = $ result ;
176- $ shortestFound = 0 ;
177187 break ;
178188 }
179189
0 commit comments